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

XF 1.2 User Profile field conditionals in CSS?

Discussion in 'Styling and Customization Questions' started by JMEWLS, Jul 28, 2013.


    JMEWLS Active Member

    Okay guys, basically on my previous vBulletin forum I implemented two things..

    1. Team rep.
    2. User background

    What I did was use profile fields for this, for the user background I just made them post the link. Then in the header I'd include..

    background-image: <if userprofile field>[user profile field]</else> default image</if>

    For the team rep I'd like to get their favorite teams background into the postbit.


    So where the username is there, I'd like to get their favorite teams background in that grey box. So I'm thinking I can add an if conditional to the message.user.info.css template or something? Just not sure how to go about it..

    Cheers guys.
  2. Brogan

    Brogan XenForo Moderator Staff Member


    JMEWLS Active Member

    Great, cheers mate.

    How about for a user background?

    JMEWLS Active Member

    Been adding this to the header with no luck...

    <xen:if is="{$user.customFields.website_background}">
    background-image: url('{$user.customFields.website_background}') !important;
    background-repeat:repeat !important;
    background-attachment: fixed !important;

    JMEWLS Active Member

    Is there no headerinclude in this? Doesn't seem to work on CSS either..
  6. Jeremy

    Jeremy XenForo Moderator Staff Member

    $user isn't available in CSS or the header template. Try $visitor.

    JMEWLS Active Member

    visitor seems to works.

    Just for future reference, what's the difference?
  8. Jeremy

    Jeremy XenForo Moderator Staff Member

    It depends on the context. Visitor usually implies the visitor to the page and user usually implies a static user. Templates only have access to variables provided to them, meaning some variables aren't accessible everywhere.
    JMEWLS likes this.

    JMEWLS Active Member

    Fair enough, I'm also kind of confused with template conditionals for usergroups. I'm trying to color a background a different color if they're part of a certain usergroup.

    <div class="userText" style="background-color: <xen:if is="{xen:helper ismemberof, $visitor, 38}">#C90; <xen:else />#EDEDED;</xen:if> text-shadow:1px 1px #FFF; text-align:center; border-bottom: 1px solid #d8d8d8; width:112px; padding:5px;">

    It just seems to color everyone the first color though. If my conditional right? It's in the message_user_info template.

    @King Kovifor
  10. Jeremy

    Jeremy XenForo Moderator Staff Member

    Are you a member if usergroup #38? Change that to $user and it should be the poster's info being checked.
  11. JMEWLS

    JMEWLS Active Member

    Cheers, works a charm.

Share This Page