1. 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

Discussion in 'Styling and Customization Questions' started by woody, Mar 13, 2014.

  1. woody

    woody Member

    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 :)
     
  2. woody

    woody Member

    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?
     
  3. Chris D

    Chris D XenForo Developer Staff Member

    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}
     
  4. woody

    woody Member

    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: Mar 17, 2014
  5. Bob

    Bob Well-Known Member

    you are using 'code_navbar' in your template (in post 1) when you need to be using 'block_navbar'
     
  6. woody

    woody Member

    sorry, too much editing...it's correct as displayed/entered...will edit above.
     
  7. Chris D

    Chris D XenForo Developer Staff Member

    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}">
     
  8. woody

    woody Member

    ah HAH!

    Thank you Chris! Seems to be working perfectly now :)
     
    Russ likes this.

Share This Page