Help with understanding Hooks

I'm just getting into my first CS-cart site design and I'm having some issues getting hooks working. I have done a fair amount of research on how to use them, but there is also a lot of older information out there that is confusing me on how to use them. I'm just trying to make a simple test hook work to figure it out. I'm trying to override the top.tpl file in the index:main_content hook. So I'm just going to go through what I steps I have taken to try and get them working.


  1. Make sure you have “My Changes” add-on enable in add ons under admin in the cart settings.


  2. Create a folder in your active skin folder. This is a litte confusing. I've seen a lot of conflicting information on the folder structure, but I'm currently using this:





    /skins/MY_SKIN_NAME/customer/addons/my_changes/hooks/index/


  3. Create a file in /skins/MY_SKIN_NAME/customer/addons/my_changes/hooks/index/ called “main_content.override.tpl”


  4. Place my code in that file




    hooked up



5. Save and upload.

6. Clear your browser cache and refresh the page.


So I'm just expecting to see "Hooked up" at the top of my page in an

. But I'm still just getting the same old header. Any ideas on what I'm doing wrong?

[quote name='pablo631' timestamp='1323283916' post='127453']

I'm just getting into my first CS-cart site design and I'm having some issues getting hooks working. I have done a fair amount of research on how to use them, but there is also a lot of older information out there that is confusing me on how to use them. I'm just trying to make a simple test hook work to figure it out. I'm trying to override the top.tpl file in the index:main_content hook. So I'm just going to go through what I steps I have taken to try and get them working.


  1. Make sure you have “My Changes” add-on enable in add ons under admin in the cart settings.


  2. Create a folder in your active skin folder. This is a litte confusing. I've seen a lot of conflicting information on the folder structure, but I'm currently using this:





    /skins/MY_SKIN_NAME/customer/addons/my_changes/hooks/index/


  3. Create a file in /skins/MY_SKIN_NAME/customer/addons/my_changes/hooks/index/ called “main_content.override.tpl”


  4. Place my code in that file




    hooked up



5. Save and upload.

6. Clear your browser cache and refresh the page.


So I'm just expecting to see "Hooked up" at the top of my page in an

. But I'm still just getting the same old header. Any ideas on what I'm doing wrong?
[/quote]

In the latest version the main_content hook will not replace any information it will just append whatever information you put in there to the top of the page.

{hook name="index:main_content"}
{/hook}

[quote]

In the latest version the main_content hook will not replace any information it will just append whatever information you put in there to the top of the page.

[/quote]



Huh? Not in my version of 2.2.4. It does what it always does is encloses the include of top.tpl.



@pablo631

[quote]

6. Clear your browser cache and refresh the page.

[/quote]

You actually want to clear the site's page cache via yourdomain.com



You can also just put {debug} into your hook to see that it's working. This has the added benefit of displaying the template variables that are available to your hook.



You should only have to clear the site cache once per added hook. After that, hooks are read in real-time after they are established.

Ahh ok, That ?cc did the trick. Thanks.



So if I want to move things around in the top.tpl, do I just place al the code from top.tpl in my hook then adjust the code?

[quote name='tbirnseth' timestamp='1323294008' post='127469']

Huh? Not in my version of 2.2.4. It does what it always does is encloses the include of top.tpl.



@pablo631



You actually want to clear the site's page cache via yourdomain.com



You can also just put {debug} into your hook to see that it's working. This has the added benefit of displaying the template variables that are available to your hook.



You should only have to clear the site cache once per added hook. After that, hooks are read in real-time after they are established.

[/quote]

yea my bad sorry for any confusion this may have caused, I think I might have made that change myself a while back and totally forgot about it.

@pablo631 - that is generally the approach to take when you just want to modify what's there, but keep most. Otherwise re-do and have at it.

How to use hooks? any link that explain this in details? i want to use my own html header and footer on the cs-cart.

An old document I wrote is at http://www.ez-ms.com/docs/customizing_your_store.pdf

Just change references from 'local' to 'my_changes' and you should be fine. The concepts are all the same.

The document was written before my_changes existed.