Template Hooks

Daniel Hood

Well-known member
Since template hooks are depreciated, how are you guys going about using the existing ones? Do you just use them as you did before, do you use a template mod regex find/replace to add your content inside the hooks, or do you avoid the hooks entirely and use template modifications to append to something else?
 
I try to avoid template hooks completely now.

That being said, the advertising system for AVForums relies heavily on them. But I have a plan in case they're ever completely removed from the core. The concept was devised actually before they were deprecated.

But when developing anything, that is what is in the back of my mind. What if 1.3 comes along and that template hook isn't there anymore? Or worse, the entire code event is removed?

So best bet is to completely avoid them.
 
You should be using template modifications and migrating any pre-existing addons to the template modifications. Hooks can be removed at any time.
 
Alright, I figured it would be best to avoid template hooks. Just looking for the best alternative.

What replacement method would you use for this, for example? To add something after the trophy points line.

Code:
<dl class="userStats pairsInline">
         <xen:hook name="member_card_stats">
             <dt>{xen:phrase member_since}:</dt> <dd>{xen:date $user.register_date}</dd>             <!-- slot: pre_messages -->
             <dt>{xen:phrase messages}:</dt> <dd><a href="{xen:link search/member, '', 'user_id={$user.user_id}'}" class="concealed" rel="nofollow">{xen:number $user.message_count}</a></dd>             <!-- slot: pre_likes --> 
            <dt>{xen:phrase likes_received}:</dt> <dd>{xen:number $user.like_count}</dd>             <!-- slot: pre_trophies -->
             <dt>{xen:phrase trophy_points}:</dt> <dd><a href="{xen:link members/trophies, $user}" class="concealed OverlayTrigger">{xen:number $user.trophy_points}</a></dd>             <xen:if is="{$canViewWarnings}">
                 <dt>{xen:phrase warning_points}:</dt> <dd><a href="{xen:link members, $user}#warnings" class="concealed">{xen:number $user.warning_points}</a></dd>             </xen:if>
         </xen:hook>
         </dl>
 
Before now I've written ridiculously complicated regular expressions to do replacements such as the above. But actually, a lot of the time simple string replacements - as long as you're smart and don't do things like search/replace entire templates or across multiple lines. Although that will work, the more you match as a simple string I guess the more likely you are going to have problems come upgrade time.
 
Back
Top Bottom