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

Custom Profile Preference Field Conditional

Russ

Well-known member
#1
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.png
ex2.png

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.
 

Russ

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

Chris D

XenForo developer
Staff member
#6
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>