1. 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

Discussion in 'XenForo Questions and Support' started by AdamCapriola, May 24, 2012.

  1. AdamCapriola

    AdamCapriola Member

    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).
    <xen:if is="thread or conversation">
    <xen:require js="path/to/my/file.js" />
    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!
  2. Chris D

    Chris D XenForo Developer Staff Member

    I think you're missing something. It would be more like:

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

    ragtek Guest

    it should be OR and not AND
    AdamCapriola and Yorick like this.
  4. Chris D

    Chris D XenForo Developer Staff Member

    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.

Share This Page