Conditional Statements for XenForo 2

Conditional Statements for XenForo 2

@ge66 Thanks for your reply.

As I'm a bit 'dense', would it be possible for you to explain to me in small steps exactly what I need to do here, as I think I DID check the 'Advanced' mode.
 
My thread view shows 20 posts per page, here is a snippet that will show your content in the 1st, 10th and 20th posts.
HTML:
<xf:if is="in_array($post.position % $xf.options.messagesPerPage, [0, 9, 19])">
    Show Content...
</xf:if>
I use it in "Post: Below message content" in the advertisement control panel to show ads, 3 per page.
 
My thread view shows 20 posts per page, here is a snippet that will show your content in the 1st, 10th and 20th posts.
HTML:
<xf:if is="in_array($post.position % $xf.options.messagesPerPage, [0, 9, 19])">
    Show Content...
</xf:if>
I use it in "Post: Below message content" in the advertisement control panel to show ads, 3 per page.

I'm looking for an option that shows it before the last post in a topic. Does anybody has this working? After last post is working but want is just before it.
 
I used to have a different logo banner for each one of my subforums and that was all ran by a conditional statement in the logo_block template. Since I have switched to XF2 I am not sure where to place this kind of snippet of code.

Code:
<xen:hook name="header_logo">
<div id="logo"><a href="{$logoLink}">
<span><xen:comment>This span fixes IE vertical positioning</xen:comment></span>
<xen:if is="{xen:property uix_logoText}"><h2 class="uix_logoText"><xen:if is="{xen:property uix_logoTextIcon}"><i class="uix_icon {xen:property uix_logoTextIcon}"></i></xen:if>{xen:property uix_logoText}</h2><xen:else /><img src="{xen:property headerLogoPath}" alt="{$xenOptions.boardTitle}" /></xen:if>
<xen:if is="{xen:property uix_sloganText}"><div class="uix_slogan">{xen:property uix_sloganText}</div></xen:if>
<xen:if is="{$forum.node_id} == 25">
<img src="{xen:property imagePath}/uix_dark/tabletop.png" alt="{$xenOptions.boardTitle}" />
<xen:elseif is="{$forum.node_id} == 3" />
<img src="{xen:property imagePath}/uix_dark/othergames.png" alt="{$xenOptions.boardTitle}" />

I just snipped the first couple of lines.
 
It's shifted to PAGE_CONTAINER <div class="p-header-logo p-header-logo--image">.
You will need to adjust your code, though. XF2 has a slightly changed syntax.
 
Probably something like this
HTML:
<xf:if is="!in_array({$__globals.template}, ['register_form', 'login'])">
content
</xf:if>
 
Any way to do a random in XF2? I want my pop up ads to only run in 1 of every 5 pages or something like that. Any ideas?
 
I am trying to hide the default rel=canonical link for a specific resource, and show a custom rel=canonical link for that resource

Does anyone know how I would do that?

Thanks
 
I have this condition in my XF1 "message_user_info" template:

<xen:if is="{xen:helper ismemberof, $user, 152}">

How I can modify/translate it for XF2 template "message_macros"?
 
--- 13.a Show content for only one user group
Replace $xf.visitor with $user or whatever the user variable is called in message_macors
 
How would I make it conditional on a style ID, please?

I've tried this:

Code:
<xf:if is="$xf.visitor.style_id == X">
    <xf:widget key="widget_name" />
</xf:if>

but it didn't seem to work, but I'm unsure how to correct it.
 
Last edited:
I just tried the following and that didn't work either:

Code:
<xf:if is="$style_id == 'x'">
    <xf:widget key="widget_name" />
  </xf:if>

In both instances, the widget shows regardless of the style which means I'm still getting the conditional wrong.
 
Hello,

can I check the "Custom user fields"? I have use the Check boxes with only 1 choice "accept"
 
Top Bottom