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

XF 1.1 Custom Field Conditionals

Discussion in 'XenForo Questions and Support' started by DBA, Oct 12, 2012.

  1. DBA

    DBA Well-Known Member

    Ok so I'm trying to add a custom field that will allow members to enable viewing images in signatures. My idea was to create a new checkbox custom field that says "Check box to enable images in signatures". However I'm having some issues with the conditionals.

    By default it should display:
    Code:
    .signature .bbCodeImage
    {
        display: none !important;
    }
    And after checking the box the above code would no longer be displayed.

    My thought process was something like this (not valid code :p).
    <xen:if customField is unhecked>
    .signature .bbCodeImage
    {
    display: none !important;
    <xen:else />
    </xen:if>

    Any ideas?
     
  2. Russ

    Russ Well-Known Member

    Idea seems right, just remember I don't think the conditional will work inside the css files so you'll need to throw it in the header.*

    *I think :)
     
  3. cclaerhout

    cclaerhout Well-Known Member

    You can't use xen tags inside css templates. You can use them in the "normal template":
    1) with a the style element
    HTML:
    <div style="{xen:if "{$variable}", "OK Then A", "NOT OK Then B"}>dzdzd</div>
    2) with a different css template
    Code:
    <xen:if customField is unhecked>
    <xen:require css="templateA.css" />
    <xen:else />
    <xen:require css="templateB.css" />
    </xen:if>
     
  4. DBA

    DBA Well-Known Member

    Well that explains that, thanks guys.

    This ended up working for me.
    Code:
    <xen:if is="!{$visitor.customFields.sig} =='on'">
    <xen:require css="sig_image.css" />
    </xen:if>
     
    Jake Bunce likes this.
  5. cclaerhout

    cclaerhout Well-Known Member

    What I've said above seems to be incorrect: The css template 'editor_ui.css' do have conditionals.
     

Share This Page