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

Xen:If Conditional For Threads and Coversations

#1
I tried Googling and searching for this, but couldn't find anything. I have a template I'm including with an addon that loads some JS, but I want to only load the JS when viewing thread and conversation pages (it has no function unless on those pages, so I figure the extraneous loads should be removed).
HTML:
<xen:if is="thread or conversation">
<xen:require js="path/to/my/file.js" />
</xen:if>
I'm guessing the check has to be for the templates conversation_list and thread_list maybe, but I'm not sure of the syntax. Thanks in advance for any help!
 

Chris D

XenForo developer
Staff member
#2
I think you're missing something. It would be more like:

Code:
<xen:if is="{$controllerName} == 'XenForo_ControllerPublic_Thread' OR {$controllerName} == 'XenForo_ControllerPublic_Conversation'">
<xen:require js="path/to/my/file.js" />
</xen:if>
There's also $contentTemplate and $controllerAction and a few other useful ones too. But I believe the above should do it.
 

Chris D

XenForo developer
Staff member
#4
Thanks ragtek :eek:

Don't know what I was thinking there!

I updated my original post to avoid confusion for anyone who may stumble upon it in the future.