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

Conditional help

Discussion in 'Troubleshooting and Problems' started by Ranger375, Nov 7, 2010.

  1. Ranger375

    Ranger375 Well-Known Member

    I'm basically trying to edit the member_user_info template for all my user groups but I am having problems. How would I make the below appear for just admins with an if conditional?

    <span class="userrank">Admin</span>



    I've searched the forum but havent found an answer :\
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    Admin CP -> Appearance -> Templates -> message_user_info

    Add this code:

    Code:
    		<xen:if is="{$user.is_admin}">
    			<span class="userTitle">ADMIN RANK</span>
    		</xen:if>
    
    ...as shown below:

    Code:
    <xen:if is="!{$isQuickReply}">
    	<h3 class="userText">
    		<a {xen:if $user.user_id, 'href="{xen:link members, $user}" '}class="username" itemprop="name">{xen:helper richUserName, $user}</a>
    		<xen:if hascontent="true"><em class="userTitle" itemprop="title"><xen:contentcheck>{xen:helper userTitle, $user}</xen:contentcheck></em></xen:if>
    
    		<xen:if is="{$user.is_admin}">
    			<span class="userTitle">ADMIN RANK</span>
    		</xen:if>
    
    	</h3>
    
    	<xen:if hascontent="true">
    		<div class="extraUserInfo">
    
    This is what you get (the rank below the title):

    Screen shot 2010-11-07 at 4.10.08 PM.png
     
  3. Ranger375

    Ranger375 Well-Known Member


    Thanks, Jake. I've been trying to figure out how to get the conditionals to work with the css ranks here: http://xenforo.com/community/threads/user-ranks-in-css-no-images-required.7731/#post-108349

    Basically, the rank appears like your example above, but without the same appearance. When I use the example in the post above, the rank appears on everyones post regardless of user group.
     
  4. Ranger375

    Ranger375 Well-Known Member

    Ahhh nm, he updated the post with

    <xen:if is="{$user.is_admin}">
    <span class="userrank">Administrator</span>
    </xen:if>


    Thanks again Jake
     
  5. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

  6. Ranger375

    Ranger375 Well-Known Member

    Thanks, that worked perfectly. How would I figure out what to write in the conditional for my custom usergroups? <xen:if is="{$user.is_?????}"> I tried putting in the group and the group number but it didn't work.
     
  7. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    This will check an individual primary usergroup:

    Code:
    <xen:if is="{$user.user_group_id} == 2">
    
    </xen:if>
    
    Change the 2 to the user_group_id you want to check.
     
    Ranger375 likes this.
  8. Ranger375

    Ranger375 Well-Known Member

    ahhh, looks like I will have to kiss secondary groups buh bye for now. Thanks again!
     
  9. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    I haven't yet found a way to operate on secondary groups using the built-in template functions. I have suggested it.
     
    Ranger375 likes this.

Share This Page