Conditional Statements for XenForo 2

Conditional Statements for XenForo 2

JoyFreak

Well-known member
It also depends on the Feedback controller action as I don't know its structure, but following should work.

HTML:
<a href="{{ link ( 'feedback/add-feedback', $post.User, {'noRedirect':1, 'threadId':$post.thread_id}) }}" class="userTitle" data-xf-click="overlay">

Can you paste a working link from another template? The link for feedback/add-feedback?
I copied and pasted the above directly and it worked! No idea what I did wrong, thank you so much!
 

NinaMcI

Active member
What would the conditional statement be to show content on a specific Member Stats page. I see the template is member_notable, but what if I only want to display on .../members/?key=member_stat_key for example?
 

smozgur

Active member
What would the conditional statement be to show content on a specific Member Stats page. I see the template is member_notable, but what if I only want to display on .../members/?key=member_stat_key for example?

HTML:
<xf:if is="$active.member_stat_key == 'most_messages'">
    we are in the "most messages" page
</xf:if>
 
Last edited:

JoyFreak

Well-known member
Trying to display a user's custom title in the accounts details page as follows: <xf:usertitle user="$xf.visitor" />
But doesn't work.
 

smozgur

Active member
Trying to display a user's custom title in the accounts details page as follows: <xf:usertitle user="$xf.visitor" />
But doesn't work.
It should. Are you sure using the "account_details" template?
Perhaps you can show your implementation.
 

smozgur

Active member
What do you mean?

I don't know how you implemented it. I don't know where you put it, perhaps in a condition or something? Perhaps you did it wrong somehow, but I wouldn't know unless I see it.

So I was trying to provide further help after confirming the code you are using is supposed to work.
 

Brogan

XenForo moderator
Staff member
It works fine.

1605124787798.png

1605124797673.png

However, this is not a conditional statement so I'm not sure why you've posted in this thread.
 

JoyFreak

Well-known member
I'm trying to use: <xf:if is="$xf.visitor.is_admin && $template == 'thread_view_type_article'">

But for some reason, it doesn't work in template thread_view. Any reason why that is?

Edit: I'm trying to make something show in the thread_view but in the thread_view_type_article, I want it to show only for admins.
 

smozgur

Active member
I'm trying to use: <xf:if is="$xf.visitor.is_admin && $template == 'thread_view_type_article'">

But for some reason, it doesn't work in template thread_view. Any reason why that is?

Edit: I'm trying to make something show in the thread_view but in the thread_view_type_article, I want it to show only for admins.

{{dump(vars())}} is your best friend when you are working with template variables.

Try following:

HTML:
<xf:if is="$xf.visitor.is_admin && $xf.reply.template == 'thread_view_type_article'">
 

JoyFreak

Well-known member
{{dump(vars())}} is your best friend when you are working with template variables.

Try following:

HTML:
<xf:if is="$xf.visitor.is_admin && $xf.reply.template == 'thread_view_type_article'">
Thanks that worked!

Do you know what the if statement is for article thread types? To check if it's an article thread type.
 
Top