xen:username if the user doesn't exist?

Liam W

in memoriam 1998-2020
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
 
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.
 
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
 
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.
 
Back
Top Bottom