• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.3 radio button conditional

woody

Active member
#1
I'm trying the following code in various ad_position templates, and I'm just not seeing why it's not working...

Code:
<xen:if is="{$visitor.customFields.code_navbar.block_one} == 'off'">
display content - block one
<xen:else />
do not display content
</xen:if>

<xen:if is="{$visitor.customFields.code_navbar.block_two} == 'off'">
display content - block two
<xen:else />
do not display content
</xen:if>
Trying to allow for user selection to see or not see specific sections based on their radio button selection in their Preferences.

Thanks for any assistance :)
 

woody

Active member
#2
is my question in the wrong place? or is this conditional I'm trying to work with outside of what works/doesn't within XenForo?
 

Chris D

XenForo developer
Staff member
#3
Not sure the syntax of your custom field is correct.

What is the output in the template if you simply have this line:

{xen:helper dump, $visitor.customFields}
 

woody

Active member
#4
Code:
array(9) {
["code_navbar"] => array(2) {
["block_two"] => string(17) "block_two"
["block_one"] => string(16) "block_one"
}
}
In the output code, neither block_two or block_one are checked in my Preferences...if they are NOT checked, then this:

Code:
array(9) {
["code_navbar"] => array(0) {
}
 
Last edited:

Chris D

XenForo developer
Staff member
#7
Code:
array(9) {
["code_navbar"] => array(2) {
["block_two"] => string(17) "block_two"
["block_one"] => string(16) "block_one"
}
}
In the output code, neither block_two or block_one are checked in my Preferences...if they are NOT checked, then this:

Code:
array(9) {
["code_navbar"] => array(0) {
}
That's correct then...

They are not checked so they have no value.

So you just need to change:
Code:
<xen:if is="{$visitor.customFields.code_navbar.block_one} == 'off'">
To:
Code:
<xen:if is="!{$visitor.customFields.code_navbar.block_one}">