Conditional Statements

Conditional Statements

@Brogan
I believe the category ID isn't exposed to the template.

So you say it dosnt will work?

Hmm... thats bad. I work on a responsive grid like resource index view and it would be nice when I can make a conditional switch to select in witch categories this is enabled and in witch its like xenforo default...

Is there an other way to do what I want?
 
@Lisa, see this guide for how to use custom user fields to modify the templates, etc.

https://xenforo.com/community/resources/using-custom-user-fields-to-customise-the-layout.4015/
No, I don't think that's what I'm looking for - I think I'm explaining myself wrong :)

I've got three custom user fields - when each one has been selected I have the choices display on a specific tab in the Profile - that all works fab. What I also have is a "Add To Watch List" clicky button - which, when clicked, takes the member to the custom user fields in question to make their selection. What I want is for that Add To Watch List button to disappear if someone has already filled in the three fields, but only if all three fields have been selected, otherwise the button needs to continue to show.

I mightn't be making much sense - feeling grotty, headache and taking medication lol
 
Hi @Brogan

24. How can I show content on a specific page?
<xen:if is="{$contentTemplate} == 'xyz'">
This content will show on the xyz template
</xen:if>

Great post, thank you. Basic question, how do I identify what the template name is for a specific page? For example, I'm trying to find the template name for http://www.onefootballforum.co.uk/index.php?chat/ to display content only on the shoutbox.

EDIT: Please disregard, found it! :)

Many thanks
 
Last edited:
Is there a way to show something in ALL threads in a SPECIFIC FORUM / NODE?
I've got a banner showing in the node I want, but I'd like all threads in that said node to show the same banner.
 
I'm trying to call a template when a certain category is used.... This used to work, but doesn't appear too anymore:
Code:
     <xen:if is="{$category.node_id} == 131">
          <xen:include template="TrainingFlightSchool" />  
     <xen:elseif is="{$forum.node_id} == 127" />
          <xen:include template="TrainingSelfPaced" />
     <xen:elseif is="{$forum.node_id} == 126" />
          <xen:include template="TrainingVideos" />
     <xen:elseif is="{$forum.node_id} == 128" />
          <xen:include template="TrainingTakeAway" />
     <xen:elseif is="{$forum.node_id} == 129" />
          <xen:include template="TrainingLive" />
     <xen:elseif is="{$forum.node_id} == 151" />
          <xen:include template="TrainingCertification" />
     </xen:if>

All the "Forum.node_id"'s work, however the one that fails is the "category.node_id", I've had it working previously using the exact same syntax above... But now it's not working anymore? :S
 
Is there a conditional statement for selected languages?

Like: if user 1 has language "en" then ...
 
So I'd like to show an ad on the sidebar only for the root and not for forums/

I'm using the widget framework. Site is www.allbuffs.com

Not sure if I can do regular php inside of a template (or want to). I was thinking of checking that the URL ends in regex forums/^ maybe?
 
The latest BD Widget beta version that can be downloaded on xfrocks site uses the same conditionals as XenForo.
and it's pretty stable.
 
I would like to show a little badge for a verified members. like in twitter / fb:
bla.webp
What is the conditional to add some css code next to the nickname or avatar?
Something like:
Code:
<xen:if is="{$what_conditional?} == 'x'">
[show this code]
</xen:if>
Appreciate some help with this conditional. :coffee:
 
I would like to show a little badge for a verified members. like in twitter / fb:
View attachment 115636
What is the conditional to add some css code next to the nickname or avatar?
Something like:
Code:
<xen:if is="{$what_conditional?} == 'x'">
[show this code]
</xen:if>
Appreciate some help with this conditional. :coffee:

I assume the verified accounts will belong to a separate user group? If so, you could just use...
Code:
<xen:if is="{xen:helper ismemberof, $user, X}">
************CODE HERE*********
</xen:if>

X = user group id.

'$user' is subject to change in some templates, so depending what template you add it to, it may be something else, like '$message' for example.
 
Hello all,

I had a search and couldn't find anything on this, so I'm sorry if I've overlooked it, but I'm hoping to create a conditional that uses the visitor's current date/time (dependent on their time zone setting), is this possible?

As a very rough example of what I mean...

<xen:if is="{X} <= {visitor's current time}">
SHOW THIS
</xen:if>

Basically, if the 'current time' is less than or equal to 'later time', then show XYZ

I've tried $datetime and $servertime in a couple of various ways, but I have no idea what I'm doing lol

Thank you for any input
 
Last edited:
Back
Top Bottom