Conditional Statements

Conditional Statements

Is there a way to say call an if statement based on a hook?
Ex
<xen:if is="{$hook_name} == x">
This content will shown
<xen:else />
This content will shown
</xen:if>
 
Last edited:
I am trying to modify the avatar for the [bd] Rotating Ads, and couldn't think of any other way so I was going to modify the message template and say if hook is "ads" then use "this avatar" otherwise use the default avatar..
 
The default expression of XenForo for changing themes and language:
<xen:if is="{$canChangeStyle} OR {$canChangeLanguage}">

I want it to show only for the Members.
Is this the right approach?
<xen:if is="{$canChangeStyle} OR {$canChangeLanguage} AND {$visitor.user_id}">

Right now only works for me is this:
<xen:if is="{$canChangeStyle} AND {$visitor.user_id}">
 
Code:
<xen:if is="{$visitor.user_id} AND ({$canChangeStyle} OR {$canChangeLanguage})">
 
  • Like
Reactions: rdn
We're displaying an ad after 5th post on every page on a thread. We're also displaying ad after the messages and sometimes those 2 ads show too close to each other (5-8 posts on a page). Is there a conditional to show the first ad if the page has at least 7-8 posts? Here's the current conditional:

Code:
<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 4 AND !{$message.conversation_id}">
Show the ad/template here
</xen:if>
 
If you mean a page node, you can use the page node id.

I'm not entirely sure what you're trying to do though.
 
Are these still correct for 1.4?

I get the following error:

  1. Argument 1 passed to XenForo_Template_Helper_Core::helperIsMemberOf() must be an array, null givenin /public_html/library/XenForo/Template/Helper/Core.php, line 1344
  2. Argument 1 passed to XenForo_Model_User::isMemberOfUserGroup() must be an array, null given, called in /public_html/library/XenForo/Template/Helper/Core.php on line 1352 and defined in /public_html/library/XenForo/Model/User.php, line 1683
When I try to do:

<xen:if is="{xen:helper ismemberof, $visitor, x}">
This content will show to members of user group x
</xen:if>
 
Even the "if userid equals" ones doesn't seem to be working. It just hides it from everyone including the specified user.
 
Any idea what I'm doing wrong?

Code:
<xen:if is="{xen:helper ismemberof, $visitor, 3}">
  test
</xen:if>

That gives the errors I posted above.
 
Hmm it's the template I'm placing it in that's causing issues.

It works fine in other templates, e.g. header

This is the template I'm trying to wrap it around

Code:
  <a href="{xen:link 'forums/{$forumID}'}" class="modLink">
  <span class="itemLabel">{xen:phrase StaffRoomUnread_AdminRoom}</span>
  <span class="itemCount {xen:if {$messageCount}, 'alert'}"> {$messageCount}</span>
  </a>
 
Top Bottom