How To Add A Js Code To Head In A Specific Page

Hello,



I know there’s an answer for this on this forums somewhere, but I cant find it :confused:



My question is, how do I add a certain js code to section, but ONLY to one page, lets says page id = 1. I suppose I need to add an IF somewhere, I’ve tried it page_content post.tpl in /hooks/pages/ with {if 0 && $smarty.request.page_id eq 1} but it doesnt work. It crashes the site without {literal} tags and with {literal} tags it just doesnt work.



Any ideas?

EDIT>

So, I've added this:



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

{literal}




SOMETHING

{/literal}
{/if}

in page_content.post.tpl (it already existed). So the code was added, but not in the section.

Hi,

You can use hooks like scripts or meta



[color=#ff0000]…/[/color]addons/my_changes/hooks/index/meta.post.tpl (becouse will keep the js cache intact)

or

[color=#ff0000]…/[/color]addons/my_changes/hooks/index/scripts.post.tpl (usual hook)


```php

{if $smarty.request.page_id == 1}

{literal}


SOMETHING

{/literal}

{/if}

```



[color=#ff0000]…/[/color] depand of cs-cart version





v3.x and v4.x [color=#ff0000]{if $smarty.request.page_id == 1}…{/if} [/color]



is enough because page_id is found only on pages.view



I hope that helps,





Valentin

[color=#808080][size=2]part of hungryweb.net[/size][/color]

do not forget to add {literal} tag.



I was siting in desk for days wondering why site shows smarty error.



LOL…