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

xen:username if the user doesn't exist?

Discussion in 'XenForo Development Discussions' started by Liam W, Feb 10, 2014.

  1. Liam W

    Liam W Well-Known Member

    If the user doesn't exist, then xen:username seems to output nothing.

    How can I check for this, and output a message stating the user wasn't found?

    EDIT: It actually appears to output the link without any anchor text...

    Liam
     
  2. Chris D

    Chris D XenForo Developer Staff Member

    The xen:username helper/s will only display the information you give it. It basically requires a single parameter that is an array that contains the user_id and username of the user.

    If the user_id is 0 or blank then it will simply output the username.

    You'd more than likely be able to do something like:

    Code:
    <xen:if is="!{$user.user_id}">
         User not found
    </xen:if>
    Where $user is the name of the variable you are passing to xen:username.

    Another thing to try is {xen:helper dump, $user}. That will verify what information that array contains.
     
    Liam W likes this.
  3. Liam W

    Liam W Well-Known Member

    Thanks for the response @Chris Deeming (I really need to get this keyboard layout fixed...)...

    The issue arises as the array I pass into it only contains the user_id - it would appear the helper fetches the username from the user_id, however if it can't fetch the username then it doesn't put it in :/

    I guess it'll have to do though. It's unlikely someone will delete their account on the forum the addon is for...

    Liam
     
  4. Chris D

    Chris D XenForo Developer Staff Member

    The helper doesn't fetch anything or even attempt to. It only works with the information you give it.

    If you don't give it a username, it won't go and fetch one, it just doesn't display a username.
     
    Liam W likes this.
  5. Liam W

    Liam W Well-Known Member

    Ah yes, I see now.

    I've worked around it, thanks :)

    Liam
     

Share This Page