Conditional Statements

Conditional Statements

I have a custom field with a dropdown list. In the member_view template i would like to show the member choice of these field.
But it will be shown only the 1. and not the 2. from the dropdown list (on the image)

member_profil.webp
 
This probably isn't something a conditional can do but is there a way I can hide the Create Thread button in a specific forum? Thing is that I want users to be able to reply but not create new threads in a specific forum.
 
is it possible to hide some codes in some forums ?
as i have some adsense code ad i have some tv shows forum so i need to hide adsense there
 
@TBDragon here's what my ad_message_below template looks like. I use this to display an affilliate banner under the first post in threads but not in certain other forums. It also disables the banner in private conversations.


<xen:hook name="ad_message_below" />





<xen:if is="{$post.position} % {$xenOptions.messagesPerPage} == 0 AND !{$message.conversation_id} AND {$forum.node_id} != 12 AND {$forum.node_id} != 6 AND {$forum.node_id} != 4 AND {$forum.node_id} != 5 AND {$forum.node_id} != 39 AND {$forum.node_id} != 13 AND {$forum.node_id} != 36 AND {$forum.node_id} != 37 AND {$forum.node_id} != 14">
<center><a href="http://www.mytopo.com/search.cfm?pid=trailpeople"><img src="styles/uix/xenforo/mytopobanner.png" width="75%"></a></center>
</xen:if>
 
Is there specifics for styles? I want to show a certain object in one A style while showing another object in B style
Code:
<xen:if is="{$style_id} == x">
This content will show in style x
<xen:else />
This content will show on other styles
</xen:if>
Would that work?
 
Does this work for check-box selections? ie: content in the sidebar, "check" the box and the content shows, "uncheck" the box and the content does not show...

Field ID = content_sidebar

Possible Choices (check boxes):
- option_a name="custom_fields[content_sidebar][option_a]" value="content_a" checked="checked"
- option_b name="custom_fields[content_sidebar][option_b]" value="content_b"
- option_c name="custom_fields[content_sidebar][option_c]" value="content_c"

Code:
<xen:if is="{$user.customFields.content_sidebar}">
...content appears here...
</xen:if>

I'm already seeing I need the results from each "possible choice" since members may wish to view/remove one, two, or all three content areas....in my option list above, option_a is checked and should appear, options b and c are not checked and (doh) should not appear...
 
Last edited:
Is there a way to write a conditional using a less than operator checking the browser width?

For example:

<xen:if is="{$browser-width} < {$maxResponsiveWidth}">
This content will show if the browser is 799px or less
<xen:else />
This other content will show if the browser is wider
</xen:if>

Is this possible with template conditional code?
 
You can use a media query for CSS: Responsive Design
I'm trying to do it without using "display:none" - I can't have hidden divs in this case. I'm after more of a "if this condition is true, show this html code in a template, else, show this other code" type of set up, without hidden divs. It looks like that might not be possible, as I read through that tutorial and couldn't find a way to do exactly what I'm asking. The media queries look like they would only work with "display:none", unless I misunderstood. If it's not possible, that's fine I'll change course. But if it is and I'm just misreading, please do let me know. My brain is a little mushy today.
 
Unfortunately there isn't a conditional statement for browser width.

If you can't/don't want to use display:none then you will need to use something like JavaScript.
 
Unfortunately there isn't a conditional statement for browser width.

If you can't/don't want to use display:none then you will need to use something like JavaScript.
Sort of figured that would be the case, as I'm sure I would have come across the conditional by now with all the searching I was doing. Thanks Brogan.
 
Is there a way to check for node types - for instance, would this work: <xen:if is="{$node.node_type_id} == 'Forum'">

I'm trying to single out the "forum home", "forum thread list" and "thread display" nodes (in vb they're the forumhome, forumdisplay, and showthread) and display those specific nodes differently than all other pages/nodes on the site. Any suggestions on how I'd achieve that?
 
Use the template name.

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


To find out the name of the template: http://xenforo.com/community/threads/frequently-asked-questions.5183/#post-181112

How can I find out which template to edit?
Using your browser, view the page source and look for a line of code near the top of the page which begins
<div id="content" class="; the class is the name of the template. So for the main forum page, the line of code is:<div id="content" class="forum_list">, which makes the template forum_list.
 
Use the template name.

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


To find out the name of the template: http://xenforo.com/community/threads/frequently-asked-questions.5183/#post-181112

How can I find out which template to edit?
Using your browser, view the page source and look for a line of code near the top of the page which begins
<div id="content" class="; the class is the name of the template. So for the main forum page, the line of code is:<div id="content" class="forum_list">, which makes the template forum_list.
That's much easier than what I was doing. Thanks again Brogan... really loving this software for so many reasons (like being able to do a CMD+S or CMD+Z in the template editor, sooooo cool). Little things like that are a big deal.
 
Top Bottom