Conditional Statements for XenForo 2

Conditional Statements for XenForo 2

For some reason guys I can't get the "display on homepage only or forum_list only to work anymore". I tried the updated code but it still doesn't work. I've tried everything.

Here's the code that won't work:

HTML:
<xf:if is="$template == 'forum_list'">
Show content...
</xf:if>

Any ideas?
 
Does anyone know how to add specific posts numbers like ( odd or even numbers ) ?

<xf:if is="{$post.position} % {$xf.options.messagesPerPage} == ">
</xf:if>
 
Does anyone know how to add specific posts numbers like ( odd or even numbers ) ?

<xf:if is="{$post.position} % {$xf.options.messagesPerPage} == ">
</xf:if>

In conditions you can do similar stuff that you would do in PHP code if I am not mistaking.
So something like that should work :
HTML:
<xf:if is="{{ ($post.position % $.xf.options.messagesPerPage) == your_value_here }}">
 
Tell me how to make the condition of the position of the widget?
For example, if the widget is in the "A" position, the title is displayed, if there is no header in the "B" position.
 
Just to update this thread. I found the solution to my homepage only display condition not working. I don't want anyone to get confused which is why I'm posting this. It works just fine. It was an issue with where I had placed the code in my template. The condition works
 
Great list. Just some minor remarks:

#6
The ! has to be removed in this conditional statement: <xf:if is="!$xf.visitor.user_id"> - !$xf.visitor.user_id are guests


Title of #15 must be "first post on each page of a thread"
The conditional statement for only the first post of a thread is <xf:if is="$post.isFirstPost()">
 
Why do you want to check this with a conditional statement - what do you want to accomplish? You can use css classes and media queries to show or hide something for mobile users, if that's your goal.
 
@krieglich I want to serve small advertisements or large advertisements based on screen width. Not the most ideal situation but this one advertiser actually serves decent ads that are not garbage. I don't think this is possible with the @media queries...but I'm not pro either.

I have this one advertiser that uses iframes that are not responsive. I have tried wrapping the iframe with my own style and modifying the iframe tags but when the iframe gets "injected" it escapes it and blows the whole page open. So my whole site is responsive except for this giant advert. When I had VB I just checked the styleid against the mobile styleid
 
@Anomandaris If the advertiser doesn't overwrite it with his own important classes, I would do it like that:

HTML:
<div class="advertising">
   <iframe ....></iframe>
</div>

and in Template extra.less:

CSS:
// Default (mobile first)
.advertising iframe {
    width: 100% !important;
    max-width: @xf-responsiveNarrow !important;
}

// Medium width (max-width is whatever you set up in page setup for medium)
@media (min-width: @xf-responsiveMedium) {
    .advertising iframe {
        max-width: @xf-responsiveMedium !important;
    }
}

// Wide width (max-width is whatever you set up in page setup for wide)
@media (min-width: @xf-responsiveWide) {
    .advertising iframe {
        max-width: @xf-responsiveWide !important;
    }
}
 
Maybe I'm blind but I can not find the conditional statement for xf 2.
How can I show content in a specific thread?

In xf1 it was:

Code:
<xen:if is="{$thread.thread_id} == x">

This content will show in thread x
</xen:if>
 
Top Bottom