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

Display User Title only if Custom?

Discussion in 'Styling and Customization Questions' started by Staxed, May 29, 2011.

  1. Staxed

    Staxed Active Member

    I'm using the mod to have user rank images (CSS version), so I commented out the line in the message_user_info that displays the User Title.

    I have a member though asking about custom user titles, so I was wondering if there is a variable that can tell if a user has a custom title or not?

    What I would like to be able to do, is put an if statement around the usertitle display code that will only show it if the user has a custom title.

    If there is no way to say "If user has CustomTitle", then how would I go about doing "If user title != ManuallyTypedDefaultTitles"?
     
  2. Wuebit

    Wuebit Well-Known Member

    I think
    HTML:
    <xen:if hascontent="true"><xen:contentcheck>{xen:helper userTitle, $user}</xen:contentcheck></xen:if>
    migth work around it
     
  3. Staxed

    Staxed Active Member

    That's the default code to display the User Title, it doesn't differentiate between a default and a custom title at all. I don't want any default titles to show, only custom titles. So I'm trying to figure out how I can add check into that if statement to either only display custom titles, or I could manually say "If user title = Adminstrator (etc), do not display).
     
  4. Wuebit

    Wuebit Well-Known Member

    Well I didn't look at the default code that was of the top of my head
    go to your admincp >> users and override each user groups title as nothing so than when they add one is will show vs not
     
  5. James

    James Well-Known Member

    This will show any user title though (including the default user title ladder). I'm not sure if it's possible... unless you create an array of all the default user titles and say (in code, obviously) "if user title != array of default titles, display user title"

    EDIT: or try vodkaholic's method ;)
     
  6. Staxed

    Staxed Active Member

    I wouldn't mind doing that, my only issue is I don't know how to do it in code. I'd even be happy just adding a bunch of != statements into the xen:if, I'm not sure how to write it though.

    That would remove the titles from the Info Card as well, which I don't want :D
     
  7. Wuebit

    Wuebit Well-Known Member

    So on the cards you want it to say "new member" as example and not on the thread list?
     
  8. Staxed

    Staxed Active Member

    Correct, I want the User Title to show in the User Card, but on the actual thread view I have images that show the default usertitles, so it would be redundant to show the default titles as well, so I only want it to show Custom Titles people have.
     
  9. Wuebit

    Wuebit Well-Known Member

    Don't think that could be done but someone else might know.
     
  10. James

    James Well-Known Member

    My installation is completely broke ATM due to my server so I can't check it.
    General Q: is it possible to grab a default user title without needing an array of user info?
     
  11. Mike

    Mike XenForo Developer Staff Member

    {$user.custom_title}

    It only has a value if they have a custom title. Replace the {xen:helper userTitle, ...} with that in the places that you want to only display with the custom title.

    You may also wish to use <xen:if is="{$user.custom_title}">...</xen:if> to wrap areas that should only be displayed if there's a custom title.
     
    Nasr, Vodkaholic, James and 1 other person like this.
  12. Staxed

    Staxed Active Member

    awesome, thanks so much :D
     
  13. Mouth

    Mouth Well-Known Member

    Necromancer hat on .... I used the following;
    Code:
    <xen:if hascontent="true"><em class="userTitle" itemprop="title"><xen:contentcheck>{$user.custom_title}</xen:contentcheck></em></xen:if>
     

Share This Page