Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

Add Css And Js To Specific Pages Only Rate Topic   - - - - -

 
  • sarathlal
  • Advanced Member
  • Trial users
  • Join Date: 04-May 16
  • 57 posts

Posted 12 May 2016 - 10:14 AM #1

Now I know how to add custom js and css using My Changes addon .

 

But how I can add js and css to specific pages only?

 

I got a related forum thread and the answer not works in version 4.3!

 

The thread says that I have to add condition in scripts.post.tpl file.

{if $controller == 'pages' && $mode== 'view' && $smarty.request.page_id == 123}

The 123 is our page ID. But it not works.

 

Can any one help me?



 

Posted 12 May 2016 - 12:42 PM #2

hi there,

 

I think you can do this by putting 123 like "123"

{if $controller == 'pages' && $mode== 'view' && $smarty.request.page_id == "123"}

or else try printing value of page id in tpl then put condition.

-Himanshu



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 23049 posts

Posted 12 May 2016 - 02:29 PM #3

In the latest versions please try:

{if $runtime.controller == 'pages' && $runtime.mode == 'view' && $smarty.request.page_id == "123"}
    <link href="" ... />
{/if}

GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)


 
  • straygecko
  • Advanced Member
  • Members
  • Join Date: 01-May 13
  • 93 posts

Posted 12 May 2016 - 02:47 PM #4

Try:

{if $location_data.dispatch == 'pages.view' && $page.page_id = 123}

in scripts.post.tpl for js and in styles.post.tpl for css/less.  Or put them in head_scripts.post.tpl if you want them separately loaded instead of sucked into the cs-cart combined files.



 
  • sarathlal
  • Advanced Member
  • Trial users
  • Join Date: 04-May 16
  • 57 posts

Posted 13 May 2016 - 05:07 AM #5

Thank you all...

 

In version 4.3,

{if $runtime.controller == 'pages' && $runtime.mode == 'view' && $smarty.request.page_id == "123"}
    <link href="" ... />
{/if}

or

{if $location_data.dispatch == 'pages.view' && $page.page_id == "123"}
    <link href="" ... />
{/if}

works perfectly.

 

Thanks to @straygecko for additional tip.



 
  • robert89
  • Advanced Member
  • Members
  • Join Date: 15-Feb 16
  • 60 posts

Posted 31 May 2016 - 08:31 PM #6

Hello

 

Can somebody help me please...

My platform is www.zenon.ro and now i see that i have 700 requests....  :(

 

O lot of request is like this:

 

"

data:image/gif;base64,R0lGODlhAQABAIA… 0 B

 

How can i take this out from the website???



 
  • eComLabs
  • CS-Cart Expert
  • Authorized Reseller
  • Join Date: 27-Jan 14
  • 23049 posts

Posted 01 June 2016 - 07:25 AM #7

Looks like the issue is theme related and caused by images lazy load. Please contact theme developers and ask them about it


GET A FREE QUOTE | CS-Cart Add-ons | CS-Cart Licenses | CS-Cart Development | CS-Cart Design | Server Configuration | UniTheme and YOUPI
CS-Cart                USD 1210     Multi-Vendor              USD 1250    Multi-Vendor PLUS           USD 3100 (2775)
CS-Cart Ultimate  USD 4025     CS-Cart + YOUPI      USD 1459      Multi-Vendor Ultimate       USD 7500 (6000)