Using Hooks

I have read the Docs and KB and cannot seem to fully understand how to make it happen.

I want to work on most parts of the CSS, othe “style.css and style.base.css”.

Can I just create the hook file and copy all the codes from the CSS files in there and make the changes in the hooks file or do i have to create separate files for each change that I want in the CSS? Meaning, a separate hooks file for the text, links, etc, and another hooks file for other changes in the design.



I sure hope that I have made my question clear enough to get help. If not please ask for clarity.

Help Anyone!



Thanks

I think you’ve got the idea a bit wrong.



CSS is not place in hooks. You can include a link to another CSS file in the “top.tpl” file if you wish or you can place CSS inline (although this is frowned upon, generally). Feel free to edit the styles.css as you please.



---------------------------------------------------



As for what template hooks are, perhaps this will help:



Inside both the PHP and the template files there are “hooks”. Each hook exists as a means for you to run your own code (PHP) or insert your own HTML (template).



So, if you look into a template, you might see an opening and closing hook:

```php

{hook name=“orders:details”}

THIS IS RUN INSIDE THE HOOK


{/hook}
```

Here the hook is in the section "orders" and the hook name is "details". So, if we want to insert our own stuff here, we need to create a template file. The question is, how does the system know where to find the template file?

When you activate an addon, it looks for hooks in the directory: /var/skins/base/addons/{NAME OF ADDON}/hooks/{SECTION}/

In this case it would be:
/var/skins_repository/base/addons/{NAME_OF_ADDON}/hooks/orders/

So now that we have a folder, we can create a template file any hook in the "orders" section (including the details). Now, the name of the template file can be:
details.pre.tpl - Place the contents of this template before the hook {hook}.
details.override.tpl - Replace the hook with the contents of this template.
details.post.tpl - Place the contents of this template after the hook {/hook}.

The good news is that the template file you create has access to all the same smarty arrays and variables in the template the hook is in. You should have access to the same user data, product data, the cart or whatever else is available.

Thanks gginorio,



I kinda think I understand what you are talking about but will look into it further. Also, I understand that regardless of using hooks to modify the skin, etc. it does not mean that upgrades will not have to be done manually. Find this quote below:



Hooks will not solve the conflict problems, this is a common

misunderstanding. If you want to keep up with the latest features and

fixes, you have to mess up with the code. A manually upgrade is necessary
.



Thanks for your help so far. Hope you and/or the forum will help me understand this even further.

If you change the basic CSS files (the base and styles css files), you will have to manually update those at upgrade time.



That said, if you use template hooks it will be easier to update any smarty code that conflicts with the new version. It won’t remove the need, but it will make it tons easier. Each time CS-Cart updates, the addons needs to be tested and a new version released if there’s a problem.