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


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?


So, I've added this:

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




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


You can use hooks like scripts or meta

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


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


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






[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,


[color=#808080][size=2]part of[/size][/color]

do not forget to add {literal} tag.

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