Custom Profile Preference Field Conditional

Russ

Well-known member
How exactly would you turn this into a working conditional? Basically I'm doing a simple profile field to allow users to choose their width of the website without having multiple styles

ex1.webp
ex2.webp

I've tried something simple like this for the purposes of testing to see if it would output anything:

Code:
<xen:if is="{$user.customFields.pagewidth} == 'Fluid Version'">
fluid is a go
</xen:if>
<xen:if is="{$user.customFields.pagewidth} == 'Fixed Version'">
fixed is a go
</xen:if>

and also:

Code:
<xen:if is="{$user.customFields.pagewidth} == 'preffluid'">
fluid is a go
</xen:if>
<xen:if is="{$user.customFields.pagewidth} == 'preffixed'">
fixed is a go
</xen:if>


I also noticed a setting in user fields "Value Display HTML" which seems like I might be able to expand on what I'm trying to achieve but I'm a coding noob sometimes. Thanks ahead of time for any help.
 
You probably want $visitor, not $user. $visitor is the current logged in user.

Got that part figured out earlier after some troubleshooting, my next question is how would the setting work with a single check box?

Code:
<xen:if is="{$visitor.customFields.pagewidth} == 'on'">
fluid is a go
</xen:if>
 
I'm also trying to add the choice of forum width. But where would i add the {$visitor.custom.xxx} at the end?
Using it in xenforo.css doesn't seem to work.

Thanks in advance!
 
You can't use HTML in CSS.

Something like this would work:

<xen:if is="{$visitor.customFields.pagewidth.on} == 'on'">
<style>
.pageWidth
{
width: 900px;
}
</style>
</xen:if>

Or instead of <style> tags you could require a different CSS file that you create yourself.

So instead of the style tags it would look like this:

<xen:if is="{$visitor.customFields.pagewidth.on} == 'on'">
<xen:require css="fixedwidth.css" />
</xen:if>
 
@Chris D @Russ
I'm trying to achieve the same but the conditional doesn't work. I want to set a conditional and display a text depending on the user selection:
1519269731577.webp
1519269852482.webp
Current user selection:
1519269798237.webp



1519269827711.webp

The conditional above isn't working. Any idea why it isn't displaying the text even when the user has set ambassador_gold option?
The template where the conditional was set is message_user_info
 
Oh, right you would want to use $user if you want to display something in a message of that user. $visitor to display something to the visitor if their custom field is that choice.
 
Top Bottom