Conditional Statements for XenForo 2

Conditional Statements for XenForo 2

awesome ty ty...

i get the first part i just dont know how to get the buttons in that or where i can put it etc...

the second part tho yeah thats pure gold if we can do that....i need the "false" verion but that seems like it shouldnt be an issue..

thank you
 
Hoping someone can help me with this one. Looking for a conditional, or perhaps not even a conditional, lol, but something to help with this:

1736058496675.webp

We have a usergroup that is occupied a single member every month. We would like to display the occupant of that group in this particular block. Is there a way to print the name of the member of this group in this block? Just simple statement that outputs the name of the member within that group?

Any help would be greatly appreciated!
 
<xf:if is="{$forum.node_id} != x"> does not work under container content above option for me.
im having trouble with this one too, i see a few posts struggled with it but i didnt see if anyone figured it out...

ive made a custom div and custom page....i need to hide the div ONLY on the custom page.
im inserting the div using a template modification so i thought that should work there...

really basic like
Code:
<xf:if is="{$forum.node_id} != 440">
    <xf:include template="my_button" />
</xf:if>

it still shows up on that page tho 🤔
 
Last edited:
What is the name of the template you are injecting your code into?

You can try adding {{ dump(vars()) }} for testing purpose, to see what variables are available.
well its my own template, but im wedging that into PAGE_CONTAINER(custom button near the scroll arrows)....ive tried putting the conditional code both inside my template and in the template modification but no joy.

ive not used that dump vars before im curious more about how it works and how to use it...

kind regards
 
ive not used that dump vars before im curious more about how it works and how to use it...
just test it (but not in a public accessible forum!). You paste the code into your template (anywhere), and you will see a list of available variables in the output. ;)

Regarding your problem: Have you tried <xf:if is="$xf.reply.containerKey != 'node-440'">?
 
just test it (but not in a public accessible forum!). You paste the code into your template (anywhere), and you will see a list of available variables in the output. ;)

Regarding your problem: Have you tried <xf:if is="$xf.reply.containerKey != 'node-440'">?
yes that worked, thank you so much 🙏
 
i realized there is one other solution for my limited case that is so obvious idk how it slipped by so ill mention case it helps anyone....

on the custom page html can just hide the div directly there with <xf:css>#div {display:none;}</xf:css>

duh, i feel so stupid lol...im happy to learned that trick tho by nocte, im pretty sure that will come in handy again.
 
To show content to members only it's simply: <xf:if is="$xf.visitor.user_id"> .
When I try this as a display condition, I get "Display condition: Line 1: Syntax error".

I am adding this to a navigation button.

Edit:
I think I just fixed via simply using "$xf.visitor.user_id" as the display condition.
 
Back
Top Bottom