Implemented [Suggestion] XenEasyTemplateHooks™ :)

Vladislav Rastrusny

Active member
All XenForo developers are waiting for template hooks to be included into XenForo. It's absolutely necessary for us ;) So, just a small idea on relatively easy implementation of this feature.

Part 1. Find/Replace.
Provide a new hook for addons
PHP:
before_template_compilation($templateName,  &$templateText)
to allow us to execute simple text find/replace operations over templates immediately before they are compiled.

Part 2. <xen:hook>
Just add compiler tag
HTML:
<xen:hook name="i_am_a_template_hook" />
and provide a new hook for addons
PHP:
process_template_hook($templateName, $hookName, $textToInsert)
. This template hook is to be called immediately before each template compilation and will allow addons to insert arbitrary HTML including XenForo template tags into templates. From what I know now about XenForo architecture, it's very easy to implement. We will be able then extend corresponding controller to inject additional data into template to be displayed, if we need.

Part 3. <xen:area>
Sometimes (rare, I think) addon needs to completely replace some contents inside template by his own version. For example, replace who is online with more advanced version, replace the data below avatar in user's profile with an improved one etc. So, tags like
HTML:
<xen:section name="i_am_a_template_section">Contents</xen:section>
can be added around specific areas inside a template and a template hook can be provided
PHP:
process_template_section($templateName, $sectionName, &$replacementText)
 
Upvote 5
This suggestion has been implemented. Votes are no longer accepted.
Top Bottom