• 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

DBA

Well-known member
#1
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?
 

Russ

Well-known member
#2
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 :)
 

cclaerhout

Well-known member
#3
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>
 

DBA

Well-known member
#4
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 :)
You can't use xen tags inside css templates.
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>