Username instead of name in articles?

General questions relating to Joomla! 3.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting.
Forum Post Assistant - If you are serious about wanting help, you should use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10
Locked
johneilif
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Sun Jul 21, 2013 4:44 pm
Location: Harstad

Username instead of name in articles?

Post by johneilif » Tue Jan 27, 2015 8:23 pm

Hello. I've searched the web a bit for some guide on how to replace the author name with author username in joomla articles in Joomla 3.. I have recently developed some sites in Both Joomla 1 and Joomla 2, but I cant figure out where and what to change in Joomla 3 to get the same effect with usernames instead of Names when it comes to articles. Does anybody know the answer for this?

itoctopus
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4025
Joined: Mon Nov 25, 2013 4:35 pm
Location: Montreal, Canada
Contact:

Re: Username instead of name in articles?

Post by itoctopus » Tue Jan 27, 2015 10:36 pm

In your article layout template, add the following code in the appropriate place:

Code: Select all

$db = JFactory::getDbo();
$sql = "SELECT username FROM #__users WHERE id='".$this->item->created_by."'";
$username = $db->loadResult($sql);
echo($username);
http://www.itoctopus.com - Joomla consulting at its finest
https://twitter.com/itoctopus - Follow us on Twitter


Locked

Return to “General Questions/New to Joomla! 3.x”