I want to add or include the following in the head tag:
<br />
<script type="text/javascript" src="/include/js/windowResize.js"></script><br />
```<br />
<br />
I know how to add this so it's included on every page, but I want it in the header of only one page.<br />
<br />
I've done this before when developing a site that uses a different CMS package that utilizes Smarty.<br />
<br />
What I did then, was to add [b]{$smarty.capture.header}[/b] just before the closing head tag in the global header template file. Then when I wanted something added to the head tag, for a specific page, I would add something like...<br />
[b]{capture name="header"}<script type="text/javascript" src="/include/js/windowResize.js"></script>{/capture}[/b]<br />
... to the top of that pages template.<br />
<br />
I can't get this to work for CS-Cart 3.x<br />
<br />
To be more specific, I want to add a certain JavaScript source to the head tag of the checkout page.<br />
<br />
Is this possible without adding it to every page?<br />
<br />
I tried adding the following just above the closing head tag of 'skins\basic\customer\index.tpl' and I also tried adding it to the bottom of 'skins\basic\customer\common_templates\scripts.tpl'<br />
```php
<br />
{$smarty.capture.header}<br />
```<br />
<br />
And the following to 'skins\basic\customer\views\checkout\checkout.tpl'<br />
```php
<br />
{capture name="header"}<script type="text/javascript" src="/include/js/windowResize.js"></script>{/capture}<br />
There is a hook for the checkout page so you can put in my_changes folder of your skin in addons folder, a new folder called checkout and then create a file scripts.pre.tpl with this script inside.
To be honest I haven't tried it in v3 but this is how it's done in v2 so it must be similar.
Fotis, thanks for the tip but that does not work. I don’t think the hooks work that way.
If I want to add a file named ‘scripts.pre.tpl’, it has to be added to the ‘\skins\basic\customer\addons\my_changes\hooks\index’ folder but that adds the contents of ‘scripts.pre.tpl’ to every page because ‘script.tpl’ loads in every page.
Unless I’m too tired and blurry eyed, I think that article you mentioned verifies what I’m saying.
Put your info in your scripts.post.tpl file inside:
{if $controller == 'checkout' }
Your script code here
{/if}
This will include your changes on all pages related to 'checkout'. If you want to be specific on the MODE or the STEP, then you'll have to add additional conditions to the if statement.
Do you mean hooks/index/scripts.post.tpl in some addon like my_changes? You should probably be using $runtime.controller and $runtime.mode. But you can verify by using:
And then searching the page source (or use browser inspector) for 'mytag:' and seeing what you get.