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

Is there a IF function available for hooks?

Hi there,

I am trying to include a template based on a specific condition. What I basically want to do is checking if the page I am accessing is a custom XF page and if so, then include a template.

In the pagenode_container template is a line which shows the pagenode_container_article content, so this would be a good start to add something. But the problem is that what I want to include is similar to a sidebar, I need to add the code at the very top. So what I need to check is something like IF this is an article, THEN include my template.

This code is what exists in the template

<xen:hook name="pagenode_container_article">
<article>{xen:raw $templateHtml}</article>
What I am looking for is something like:

<xen:hook name="pagenode_container_article">
<article>{xen:raw $templateHtml}</article>
Any idea how I could get this done? I think if I just did

<xen:hook name="pagenode_container_article">
<xen:include template="my_template">
<article>{xen:raw $templateHtml}</article>

then it would probably include my template in forum pages too, which is what I do not want. I really just want to include it if the page I am accessing is actually a PAGE.


Chris D

XenForo developer
Staff member
pagenode_container is only used in pages, e.g. http://xenforo.com/community/pages/example-page/

I think you might be getting confused with PAGE_CONTAINER

So your example code would work and only display on pages. It would not display on forums etc.

Also, technically, it's nothing to do with hooks if you're just going to directly edit the template.