1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Implemented [Suggestion] XenEasyTemplateHooks™ :)

Discussion in 'Closed Suggestions' started by Vladislav Rastrusny, Oct 18, 2010.

  1. Vladislav Rastrusny

    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
    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
    <xen:hook name="i_am_a_template_hook" />
    and provide a new hook for addons
    . 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
    <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
    process_template_section($templateName$sectionName, &$replacementText)

Share This Page