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

How does Code Event Listener: template_create work?

Discussion in 'XenForo Development Discussions' started by Jaxel, Mar 11, 2011.

  1. Jaxel

    Jaxel Well-Known Member

    I'm trying to set up a template_create listener... template_create
    Basically, whenever a specific template is called, I want to attach an additional template immediately afterwards. If there was a hook, I could attach it to the $contents; but since its not a hook, and there is no $contents, I dont know how to attach it.
        public static function template_create($templateName, array &$params, XenForo_Template_Abstract $template)
            switch ($templateName)
                case 'node_category_level_2':
                case 'node_forum_level_2':
                case 'node_link_level_2':
                case 'node_page_level_2':
  2. Jaxel

    Jaxel Well-Known Member

    I'm an idiot... template_create is used for caching isn't it... and I can't do this, can I?
  3. Shadab

    Shadab Well-Known Member

    Although Mike was talking about template hooks, this explanation is true for the "template_create" code event as well.
  4. Mike

    Mike XenForo Developer Staff Member

    Yeah, there are no contents - it's in the constructor. You're looking for template_post_render (I believe that's the name).
  5. Mike

    Mike XenForo Developer Staff Member

    The particular templates in his code are actually created in the code, so they will have individual create/render calls. Generally what you quoted/I said is true though.

Share This Page