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

Discussion in 'Styling and Customization Questions' started by Russ, Jun 17, 2012.

  1. Russ

    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.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.
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    You probably want $visitor, not $user. $visitor is the current logged in user.
     
    Russ likes this.
  3. Russ

    Russ Well-Known Member

    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>
    
     
  4. ragtek

    ragtek Guest

    <xen:if is="{$visitor.customFields.pagewidth.on} == 'on'">
    fluid is a go
    </xen:if>

    should work:)
     
    Steve F and Russ like this.
  5. Sparkiller

    Sparkiller Member

    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!
     
  6. Chris D

    Chris D XenForo Developer Staff Member

    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>
     
    Russ likes this.
  7. Sparkiller

    Sparkiller Member

    Thank you, but where do i actually need to add this code?

    Again, thanks for the help!
     
  8. Russ

    Russ Well-Known Member

    Page_container would do the trick, only some conditionals work in css I believe, this one not.
     
  9. Sparkiller

    Sparkiller Member

    Great, that did the trick. Merci!
     

Share This Page