Hello,
I’m trying to understand how to track down which template hooks to use for what when it’s possible.
For example: this file:
```php
{if "TRANSLATION_MODE"|defined || "CUSTOMIZATION_MODE"|defined}
{/if}
{if $include_dropdown}
{/if}
{hook name="index:styles"}{/hook}
```
As you can see the "{hook name="index:styles"}{/hook}" has nothing in it but it is the last thing in the file. Can I assume that an empty hook tag at the bottom of a file automatically includes the whole file above it from this?
Now let's look at this more complex template file:
```php
{* $Id: main.tpl 10618 2010-09-13 11:50:51Z alexions $ *}
{block group="top" assign="top"}
{block group="left" assign="left"}
{block group="right" assign="right"}
{block group="bottom" assign="bottom"}
{hook name="index:main_content"}
{/hook}
{if !($controller == "index" && $mode == "index")}
{if !($controller == "checkout" && $mode == "checkout")}
{include file="blocks/search.tpl"}
{/if}
{/if}
{if $top|trim}
{$top}
{/if}
{hook name="index:columns"}
{include file="common_templates/breadcrumbs.tpl"}
{include file="common_templates/notification.tpl"}
{block group="central"}
{if $left|trim}
{$left}
{/if}
{if $right|trim}
{if !($controller == "index" && $mode == "index")}
{include file="views/checkout/components/cart_status.tpl"}
{/if}
{$right}
{/if}
{/hook}
{if $bottom|trim}
{$bottom}
{/if}
{include file="bottom.tpl"}
```
As you can see there are two hooks in this file. Let's say I wanted to hook "index:columns" hook. Does this mean that under the my_changes addon I would create directory hooks/index then I could create a file called say "columns.post.tpl" and in it I would copy just the code inside the "index:columns" hook tags, i.e.:
```php
{hook name="index:columns"}
{include file="common_templates/breadcrumbs.tpl"}
{include file="common_templates/notification.tpl"}
{block group="central"}
{if $left|trim}
{$left}
{/if}
{if $right|trim}
{if !($controller == "index" && $mode == "index")}
{include file="views/checkout/components/cart_status.tpl"}
{/if}
{$right}
{/if}
{/hook}
```
Or do I copy the whole file? But if I copy the whole file how does that work with the other hook in the file?
And now let's look at this file:
```php
{* $Id: top_quick_links.tpl 11154 2010-11-09 07:48:03Z 2tl $ *}
{hook name="index:top_links"}
{include file="common_templates/simple_search.tpl"}
{assign var="escaped_current_url" value=$config.current_url|escape:url}
{foreach from=$quick_links item="link" name="quick_links"}
{if $link.param == "index.php?dispatch=auth.login_form"}
{if $auth.user_id != "0"}
{$lang.logout}{if !$smarty.foreach.quick_links.last} | {/if}
{else}
{$link.descr}{if !$smarty.foreach.quick_links.last} | {/if}
{/if}
{elseif $link.param == "index.php?dispatch=profiles.add"}
{if $auth.user_id != "0"}
{$lang.edit_profile}{if !$smarty.foreach.quick_links.last} | {/if}
{else}
{$link.descr}{if !$smarty.foreach.quick_links.last} | {/if}
{/if}
{else}
{$link.descr}{if !$smarty.foreach.quick_links.last} | {/if}
{/if}
{/foreach}
{if $user_info.firstname && $user_info.lastname}
{$lang.welcome}, {$user_info.firstname} {$user_info.lastname}
{/if}
{/hook}
```
Here the hook tags surround the entire code in the file. So, why then in the first example is there a hook that's empty and at the bottom of the file seemingly doing the same thing? Perhaps it doesn't in which case, what is the difference?
Basically, I'm trying to get a good understanding of various ways hooks are defined so I can confidently use them when I need to. I have already used one but I see a lot of variation of use in the template files so I'm trying to get a grip on all these variations.
Thanks,
Reg