Conditional Statements for XenForo 2

Conditional Statements for XenForo 2

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!
 
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?
 
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:
Trying to display a user's custom title in the accounts details page as follows: <xf:usertitle user="$xf.visitor" />
But doesn't work.
 
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.
 
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.
 
It works fine.

1605124787798.webp

1605124797673.webp

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

View attachment 239547

View attachment 239548

However, this is not a conditional statement so I'm not sure why you've posted in this thread.
Sorry, at first I thought a variable can be used such as {xf.visitor.user_title} to output the value, that's why I asked here. I've also realised the reason why it didn't work is because I didn't have a custom title set for my account. Silly me. Thanks guys!
 
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.
 
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'">
 
{{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.
 
Do you know what the if statement is for article thread types? To check if it's an article thread type.
HTML:
<xf:if is="$thread.discussion_type == 'article'">
    dump(vars()) is your friend.
    And you can also use $thread variable instead of $xf.reply.template in the previous code.
</xf:if>
 
Back
Top Bottom