Add Css And Js To Specific Pages Only

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?

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

In the latest versions please try:

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

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.

Thank you all...

In version 4.3,

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

or

{if $location_data.dispatch == ‘pages.view’ && $page.page_id == “123”}

{/if}

works perfectly.

Thanks to @straygecko for additional tip.

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???

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