Conditional Statements for XenForo 2

Conditional Statements for XenForo 2

Oh man... my fault. You are right.
I also have a typo in my link, its fixed now and work like a charm. Thanks again. :)

I have to many widgets with to similar names (keys). Works like you post first above. Sorry. Its to late for a old man, I should better sleep now. ;)
 
Last edited:
How can i do this?

i try to show some content when i'm creating a thread only with an specific prefix. I don't know how i can do it...

<xf:if is="prefix_title('thread', $thread.prefix_id) == here is the value of the prefix? who can help me ? or some examples?

the value prefix is 3

1636836475549.webp
 
i try to show some content when i'm creating a thread only with an specific prefix. I don't know how i can do it...
So, you mean that once a user selects a prefix a content (block) is added to the site? Is that right? In that case you would have to use Javascript and change the site dynamically.
 
So, you mean that once a user selects a prefix a content (block) is added to the site? Is that right? In that case you would have to use Javascript and change the site dynamically.
you're right!! i try this in thread_view:
<xf:if is="prefix_title('thread', $thread.prefix_id) == 'Question'">hello</xf:if>

And it shows. ;)

So i have to do it with Javascript... is there some tutorial or example to follow? i don't know Javascript :eek:
 
I am not sure, if i understand you right. Do you want to display some content while the thread is created (dynamically depending on currently chosen thread prefix) or do you want to display some text in thread_view after the thread has been created.

If you want to do the former (dynamically while thread creation):
So i have to do it with Javascript... is there some tutorial or example to follow? i don't know Javascript :eek:
try asking here:


.. I guess that's the best place.

It's not a template code you have to choose, so this is not the right place to ask for assistance.
 
untested, but if you have access to $node you can try something like:

HTML:
<xf:if is="$node.node_type_id == 'SearchForum'">
    <!-- do something -->
</xf:if>
 
Last edited:
untested, but if you have access to $node you can try something like:

HTML:
<xf:if is="$node.node_type_id == 'SearchForum'">
    <!-- do something -->
</xf:if>
Thanks bro with the help! I try it this in template: search_forum_view (works):
Code:
<xf:if is="in_array({$searchForum.node_id}, [X,Y,Z])">
test and working only with node type forum search
</xf:if>
And this in PAGE_CONTAINER (works):
Code:
<xf:if is="in_array($containerKey, ['node-X','node-Y','node-Z'])">
    test and working with all type nodes
</xf:if>
 
Anyone know a way to insert a conditional into a widget so it doesn't display on small devices, only larger devices? I'm aware I could wrap content into a div with a class, but these specific widgets are from addons, not custom.

Thanks!
 
Anyone know a way to insert a conditional into a widget so it doesn't display on small devices, only larger devices?
not with XF Core (there you have to use CSS media-queries), but maybe you can do that with an addon by @Xon:

 
Try this:

HTML:
<xf:if is="$xf.uri == '/test/'">
     <!-- show some content -->
</xf:if>

Keep in mind, that this won't work e. g. for /test/test2/

Thats not what I want, I wanted something that looks for any instance of "test" in the uri, currently I am using javascript for this.
 
Top Bottom