user element - user name in article

joit

Active Member
Hi guys,

when I use {ElementName} to show a user name in an article, I only get the user id.
How can I show the user name?

Thanks!
 
Is your element set to display the name in its settings? I know this is the setting to display in list view. I don't know if it works for use in content. If it does not work (or suppose to work), you can always embed the PHP code in the article (using a plugin like Sourcerer) and get the name from the Joomla $user object (so long it's the name of the connected user).
 
I'm not sure what exactly you mean by
Is your element set to display the name in its settings?
so I attached a screenshot of what I think you mean. I think it's set correctly.
I hoped there is a solution like {ElementName:user name} but if there isn't, can you please give me an example of the PHP code and how I can insert it?

Thanks
 

Attachments

  • user_name.png
    user_name.png
    21.8 KB · Views: 428
Well the "User name" is not the name of the user. You'd have to set it on "Name".
However, with this setting, you should see a username in your content (something like "joit") and not the ID. If you do see the ID, maybe it is a bug or maybe this element was not meant to work in these circumstances. I can't answer to this.
So if you want to use PHP, you'd need first to install a plugin that allows you to insert PHP into your content (because without that your editor will strip the code out). I personaly use Sourcerer (http://www.nonumber.nl) but there are others (check the JED on joomla.org).
Then in your article, where you need to insert the name, you would use:
PHP:
{source}
<?php $user = JFactory::getUser();
echo $user->get('name'); ?>
{/source}

{source) is the tag used by Sourcerer to insert the code into the content. if you use another extension, you may need to use another tag.
 
That would give the current logged in user's name.

when I use {ElementName} to show a user name in an article,
Are you inserting a {fabrik view=element....} into a Joomla article, or something else? If so could you post the url to the article the full {fabrik......} text you are using and the list you are drawing the data from?
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top