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

XF 1.4 Rank as custom user filed?

Discussion in 'Styling and Customization Questions' started by Heavy, Mar 14, 2015.

  1. Heavy

    Heavy Active Member

    Hi xenForo Community!

    I would like to have User Title Override as a rank in custom user fields.

    Example
    From this: [​IMG]
    To this: [​IMG]

    Rank in custom user field instead of under username.

    Thank you so much!

    -Heavy
     
  2. Dylan V

    Dylan V Well-Known Member

    Hi,

    Go to the templates of your style and search for "message_user_info". Then, replace its content with:
    Code:
    <xen:require css="message_user_info.css" />
    
    <div class="messageUserInfo" itemscope="itemscope" itemtype="http://data-vocabulary.org/Person">  
    <div class="messageUserBlock {xen:if $user.isOnline, online}">
        <xen:hook name="message_user_info_avatar" params="{xen:array 'user={$user}', 'isQuickReply={$isQuickReply}'}">
            <div class="avatarHolder">
                <span class="helper"></span>
                <xen:avatar user="$user" size="m" img="true" />
                <xen:if is="{$user.isOnline}"><span class="Tooltip onlineMarker" title="{xen:phrase online_now}" data-offsetX="-22" data-offsetY="-8"></span></xen:if>
                <!-- slot: message_user_info_avatar -->
            </div>
        </xen:hook>
    
    <xen:if is="!{$isQuickReply}">
        <xen:hook name="message_user_info_text" params="{xen:array 'user={$user}', 'isQuickReply={$isQuickReply}'}">
            <h3 class="userText">
                <xen:username user="$user" itemprop="name" rich="true" />
                {xen:helper userBanner, $user, 'wrapped'}
                <!-- slot: message_user_info_text -->
            </h3>
        </xen:hook>
          
        <xen:if hascontent="true">
            <div class="extraUserInfo">
                <xen:contentcheck>
                <xen:hook name="message_user_info_extra" params="{xen:array 'user={$user}', 'isQuickReply={$isQuickReply}'}">
                <dl class="pairsJustified">
                    <dt>Rank:</dt>
                    <dd><xen:if hascontent="true"><em class="userTitle" itemprop="title"><xen:contentcheck>{xen:helper userTitle, $user, 1, 1}</xen:contentcheck></em></xen:if></dd>
                </dl>
                    <xen:if is="@messageShowRegisterDate AND {$user.user_id}">
                        <dl class="pairsJustified">
                            <dt>{xen:phrase joined}:</dt>
                            <dd>{xen:date $user.register_date}</dd>
                        </dl>
                    </xen:if>
                  
                    <xen:if is="@messageShowMessageCount AND {$user.user_id}">
                        <dl class="pairsJustified">
                            <dt>{xen:phrase messages}:</dt>
                            <dd><a href="{xen:link search/member, '', 'user_id={$user.user_id}'}" class="concealed" rel="nofollow">{xen:number $user.message_count}</a></dd>
                        </dl>
                    </xen:if>
                  
                    <xen:if is="@messageShowTotalLikes AND {$user.user_id}">
                        <dl class="pairsJustified">
                            <dt>{xen:phrase likes_received}:</dt>
                            <dd>{xen:number $user.like_count}</dd>
                        </dl>
                    </xen:if>
                  
                    <xen:if is="@messageShowTrophyPoints AND {$user.user_id}">
                        <dl class="pairsJustified">
                            <dt>{xen:phrase trophy_points}:</dt>
                            <dd><a href="{xen:link 'members/trophies', $user}" class="OverlayTrigger concealed">{xen:number $user.trophy_points}</a></dd>
                        </dl>
                    </xen:if>
              
                    <xen:if is="@messageShowGender AND {$user.gender}">
                        <dl class="pairsJustified">
                            <dt>{xen:phrase gender}:</dt>
                            <dd itemprop="gender"><xen:if is="{$user.gender} == 'male'">{xen:phrase male}<xen:else />{xen:phrase female}</xen:if></dd>
                        </dl>
                    </xen:if>
                  
                    <xen:if is="@messageShowOccupation AND {$user.occupation}">
                        <dl class="pairsJustified">
                            <dt>{xen:phrase occupation}:</dt>
                            <dd itemprop="role">{xen:string censor, $user.occupation}</dd>
                        </dl>
                    </xen:if>
                  
                    <xen:if is="@messageShowLocation AND {$user.location}">
                        <dl class="pairsJustified">
                            <dt>{xen:phrase location}:</dt>
                            <dd><a href="{xen:link 'misc/location-info', '', 'location={xen:string censor, $user.location, '-'}'}" target="_blank" rel="nofollow" itemprop="address" class="concealed">{xen:string censor, $user.location}</a></dd>
                        </dl>
                    </xen:if>
              
                    <xen:if is="@messageShowHomepage AND {$user.homepage}">
                        <dl class="pairsJustified">
                            <dt>{xen:phrase home_page}:</dt>
                            <dd><a href="{xen:string censor, $user.homepage, '-'}" rel="nofollow" target="_blank" itemprop="url">{xen:string censor, $user.homepage}</a></dd>
                        </dl>
                    </xen:if>
                              
                </xen:hook>          
                <xen:if is="@messageShowCustomFields AND {$user.customFields}">
                <xen:hook name="message_user_info_custom_fields" params="{xen:array 'user={$user}', 'isQuickReply={$isQuickReply}'}">
              
                    <xen:foreach loop="$userFieldsInfo" key="$fieldId" value="$fieldInfo">
                        <xen:if is="{$fieldInfo.viewable_message} AND ({$fieldInfo.display_group} != 'contact' OR {$user.allow_view_identities} == 'everyone' OR ({$user.allow_view_identities} == 'members' AND {$visitor.user_id}))">
                            <xen:if hascontent="true">
                                <dl class="pairsJustified userField_{$fieldId}">
                                    <dt>{xen:helper userFieldTitle, $fieldId}:</dt>
                                    <dd><xen:contentcheck>{xen:helper userFieldValue, $fieldInfo, $user, {$user.customFields.{$fieldId}}}</xen:contentcheck></dd>
                                </dl>
                            </xen:if>
                        </xen:if>
                    </xen:foreach>
                  
                </xen:hook>
                </xen:if>
                </xen:contentcheck>
            </div>
        </xen:if>
          
    </xen:if>
    
        <span class="arrow"><span></span></span>
    </div>
    </div>
    Result:

    Screenshot_1.png
     
  3. Heavy

    Heavy Active Member

    Will a rich name work there?
     
  4. Heavy

    Heavy Active Member

    Because mine title have a css styling, will it work?
     
  5. Dylan V

    Dylan V Well-Known Member

    This is not classified as an username, so no. However, you can add the color appropriate to the rank by replacing this:
    Code:
    <dd><xen:if hascontent="true"><em class="userTitle" itemprop="title"><xen:contentcheck>{xen:helper userTitle, $user, 1, 1}</xen:contentcheck></em></xen:if></dd>
    with this:
    Code:
    <dd><xen:if hascontent="true"><em class="userTitle" style="color: red" itemprop="title"><xen:contentcheck>{xen:helper userTitle, $user, 1, 1}</xen:contentcheck></em></xen:if></dd>
    Change "color: red" depending on what you want to. ;)

    Screenshot_2.png
     
  6. Heavy

    Heavy Active Member

    Thanks, but its a bit buggy/wrong..

    My result.. [​IMG]
    Message must be a little wider?

    And i wanted the username above the profile picture, thank you @Dylan V .
     
    Last edited: Mar 14, 2015
  7. Dylan V

    Dylan V Well-Known Member

    You need to change the width of the block. Go to "Style Properties", "Message Layout" and in "User Info Container", change "124px" with "150px". Then, go to "Content Container" and change this:

    Screenshot_3.png

    with 176px.

    Now, replace the content of the template "message_user_info" with:
    Code:
    <xen:require css="message_user_info.css" />
    
    <div class="messageUserInfo" itemscope="itemscope" itemtype="http://data-vocabulary.org/Person">
    <div class="messageUserBlock {xen:if $user.isOnline, online}">
        <xen:hook name="message_user_info_avatar" params="{xen:array 'user={$user}', 'isQuickReply={$isQuickReply}'}">
            <div class="avatarHolder">
            <xen:username user="$user" itemprop="name" rich="true" />
                <span class="helper"></span>
                <xen:avatar user="$user" size="m" img="true" />
                <xen:if is="{$user.isOnline}"><span class="Tooltip onlineMarker" title="{xen:phrase online_now}" data-offsetX="-22" data-offsetY="-8"></span></xen:if>
                <!-- slot: message_user_info_avatar -->
            </div>
        </xen:hook>
    
    <xen:if is="!{$isQuickReply}">
        <xen:hook name="message_user_info_text" params="{xen:array 'user={$user}', 'isQuickReply={$isQuickReply}'}">
            <h3 class="userText">
                {xen:helper userBanner, $user, 'wrapped'}
                <!-- slot: message_user_info_text -->
            </h3>
        </xen:hook>
        
        <xen:if hascontent="true">
            <div class="extraUserInfo">
                <xen:contentcheck>
                <xen:hook name="message_user_info_extra" params="{xen:array 'user={$user}', 'isQuickReply={$isQuickReply}'}">
                <dl class="pairsJustified">
                    <dt>Rank:</dt>
                    <dd><xen:if hascontent="true"><em class="userTitle" style="color: red" itemprop="title"><xen:contentcheck>{xen:helper userTitle, $user, 1, 1}</xen:contentcheck></em></xen:if></dd>
                </dl>
                    <xen:if is="@messageShowRegisterDate AND {$user.user_id}">
                        <dl class="pairsJustified">
                            <dt>{xen:phrase joined}:</dt>
                            <dd>{xen:date $user.register_date}</dd>
                        </dl>
                    </xen:if>
                
                    <xen:if is="@messageShowMessageCount AND {$user.user_id}">
                        <dl class="pairsJustified">
                            <dt>{xen:phrase messages}:</dt>
                            <dd><a href="{xen:link search/member, '', 'user_id={$user.user_id}'}" class="concealed" rel="nofollow">{xen:number $user.message_count}</a></dd>
                        </dl>
                    </xen:if>
                
                    <xen:if is="@messageShowTotalLikes AND {$user.user_id}">
                        <dl class="pairsJustified">
                            <dt>{xen:phrase likes_received}:</dt>
                            <dd>{xen:number $user.like_count}</dd>
                        </dl>
                    </xen:if>
                
                    <xen:if is="@messageShowTrophyPoints AND {$user.user_id}">
                        <dl class="pairsJustified">
                            <dt>{xen:phrase trophy_points}:</dt>
                            <dd><a href="{xen:link 'members/trophies', $user}" class="OverlayTrigger concealed">{xen:number $user.trophy_points}</a></dd>
                        </dl>
                    </xen:if>
            
                    <xen:if is="@messageShowGender AND {$user.gender}">
                        <dl class="pairsJustified">
                            <dt>{xen:phrase gender}:</dt>
                            <dd itemprop="gender"><xen:if is="{$user.gender} == 'male'">{xen:phrase male}<xen:else />{xen:phrase female}</xen:if></dd>
                        </dl>
                    </xen:if>
                
                    <xen:if is="@messageShowOccupation AND {$user.occupation}">
                        <dl class="pairsJustified">
                            <dt>{xen:phrase occupation}:</dt>
                            <dd itemprop="role">{xen:string censor, $user.occupation}</dd>
                        </dl>
                    </xen:if>
                
                    <xen:if is="@messageShowLocation AND {$user.location}">
                        <dl class="pairsJustified">
                            <dt>{xen:phrase location}:</dt>
                            <dd><a href="{xen:link 'misc/location-info', '', 'location={xen:string censor, $user.location, '-'}'}" target="_blank" rel="nofollow" itemprop="address" class="concealed">{xen:string censor, $user.location}</a></dd>
                        </dl>
                    </xen:if>
            
                    <xen:if is="@messageShowHomepage AND {$user.homepage}">
                        <dl class="pairsJustified">
                            <dt>{xen:phrase home_page}:</dt>
                            <dd><a href="{xen:string censor, $user.homepage, '-'}" rel="nofollow" target="_blank" itemprop="url">{xen:string censor, $user.homepage}</a></dd>
                        </dl>
                    </xen:if>
                            
                </xen:hook>        
                <xen:if is="@messageShowCustomFields AND {$user.customFields}">
                <xen:hook name="message_user_info_custom_fields" params="{xen:array 'user={$user}', 'isQuickReply={$isQuickReply}'}">
            
                    <xen:foreach loop="$userFieldsInfo" key="$fieldId" value="$fieldInfo">
                        <xen:if is="{$fieldInfo.viewable_message} AND ({$fieldInfo.display_group} != 'contact' OR {$user.allow_view_identities} == 'everyone' OR ({$user.allow_view_identities} == 'members' AND {$visitor.user_id}))">
                            <xen:if hascontent="true">
                                <dl class="pairsJustified userField_{$fieldId}">
                                    <dt>{xen:helper userFieldTitle, $fieldId}:</dt>
                                    <dd><xen:contentcheck>{xen:helper userFieldValue, $fieldInfo, $user, {$user.customFields.{$fieldId}}}</xen:contentcheck></dd>
                                </dl>
                            </xen:if>
                        </xen:if>
                    </xen:foreach>
                
                </xen:hook>
                </xen:if>
                </xen:contentcheck>
            </div>
        </xen:if>
        
    </xen:if>
    
        <span class="arrow"><span></span></span>
    </div>
    </div>
    After, go to "EXTRA.css" and add this:
    Code:
    .messageUserBlock a.username
    {
        text-align: center;
        margin-bottom: 5px;
    }
    
    .messageUserBlock div.avatarHolder .onlineMarker
    {
        top: 30px !important;
    }
    Screenshot_4.png
     
  8. Heavy

    Heavy Active Member

    Now everything is ****ed up result: :([​IMG]
     
  9. Heavy

    Heavy Active Member

    Profile picture is too small, and yeah so much more is just wrong.. please help me :(
     
  10. Dylan V

    Dylan V Well-Known Member

    Can you give an admin account with access only to styles? I can fix the problem much more quickly.
     
  11. Heavy

    Heavy Active Member

    Ok, how to?
     
  12. Dylan V

    Dylan V Well-Known Member

    You forgot to put this:
    Code:
    .messageUserBlock a.username
    {
        text-align: center;
        margin-bottom: 5px;
    }
    
    .messageUserBlock div.avatarHolder .onlineMarker
    {
        top: 30px !important;
    }
     
  13. Heavy

    Heavy Active Member

    Thread solved, thanks alot @Dylan V
     
    Dylan V likes this.

Share This Page