Hooks?

OK, I modified the Basic Skin to create a new skin for my client. I modified 25 tpl files to create the new look.



Now I want to back out the changes (quite easy using the Winmerge program) and use hooks to create the changes. I immediately ran into a problem, I do not see a hook in top.tpl and the top_menu.tpl.



In Main.tpl I see



{hook name=“index:main_content”}

{include file=“top.tpl”}


{/hook}



But am I supposed to create another top.tpl file (maybe top_new.tpl) and call it from main_content.post.tpl? I couldn’t find a similar work around for top_menu.tpl. Doesn’t it defeat the purpose of hooks if I have to create new files anyway?



I am sure I will find other changes I made that no hook exists for. How do I use hooks in these cases. What am I missing?



David

You could create the hook /skins/YOURSKIN/customer/addons/local/hooks/index/main_content.override.tpl. You could then layout your design in main_content.override.tpl without calling top.tpl. You could copy and past the bits you want from top.tpl, top_quick_links.tpl and top_menu.tpl as needed.



Bob

I was excited to try and use hooks. But after playing with it, I find them not very useful. I am not finding hooks for the code I changed and I am having to go back two or three files deep to finally find a hook I can use. By then I would have to copy several files worth of content into the hooks override file. Maybe I made too many changes to the skin. I guess if I made one or two changes they would be useful, but if you seriously change the skin they do not seem to be very helpful.



Unless someone has a better way of using hooks, I will just rename my skin and that way cs-cart will not overwrite it with an update.

Don’t forget that you can also specify a hook action of ‘pre’ or ‘post’ which affords some additional flexibility. Unfortunately, there is not currently much available in terms of hooks for the page header which is where most people make mods. Perhaps the developers need to throw some hooks into top.tpl and top.menu.tpl



The tradeoff when creating your own skin is that new features will not be ‘inherited’ as they are rolled into the script like they would when using hooks. Depending on the amount of customization, this might not be a bad thing but will leave you with a lot more work to integrate future upgrades.



Bob