Display name instead of username in Who is online module

Forum closed, please submit your tips and tricks to: http://docs.joomla.org/Category:Tips_and_tricks
Locked
Gergo Erdosi
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4031
Joined: Sat Nov 11, 2006 9:34 pm
Location: Hungary

Display name instead of username in Who is online module

Post by Gergo Erdosi » Sun Jul 13, 2008 5:33 pm

If you want to display the name of the user instead of the username in the Who is online module, you need to do the following steps. The module gets the data from the session table, but that table doesn't contain the name of the user, only the username and the userid. That's why you need to join the session and the users table in the sql query. For this open the /modules/mod_whosonline/helper.php file and change

Code: Select all

      $query = 'SELECT DISTINCT a.username' .
             ' FROM #__session AS a' .
             ' WHERE client_id = 0' .
             ' AND a.guest = 0';
to

Code: Select all

      $query = 'SELECT DISTINCT u.name' .
             ' FROM #__session AS a' .
             ' INNER JOIN #__users AS u ON u.id = a.userid' .
             ' WHERE a.client_id = 0' .
             ' AND a.guest = 0';
There is only one step left, open the /modules/mod_whosonline/tmpl/default.php file and at the bottom change

Code: Select all

<?php echo $name->username; ?>
to

Code: Select all

<?php echo $name->name; ?>
This trick was written for Joomla 1.5 and was originally posted in this topic.

User avatar
brad
Joomla! Master
Joomla! Master
Posts: 13272
Joined: Fri Aug 12, 2005 12:38 am
Location: Australia
Contact:

Re: Display name instead of username in Who is online module

Post by brad » Sun Jul 13, 2008 9:19 pm

How about putting this on docs.joomla.org ?

Gergo Erdosi
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4031
Joined: Sat Nov 11, 2006 9:34 pm
Location: Hungary

Re: Display name instead of username in Who is online module

Post by Gergo Erdosi » Sun Jul 13, 2008 9:41 pm

It's okay for me, just I don't where exactly could I place this on docs.joomla.org...

User avatar
brad
Joomla! Master
Joomla! Master
Posts: 13272
Joined: Fri Aug 12, 2005 12:38 am
Location: Australia
Contact:

Re: Display name instead of username in Who is online module

Post by brad » Sun Jul 13, 2008 9:50 pm

erdsiger wrote:It's okay for me, just I don't where exactly could I place this on docs.joomla.org...
Just add it, and we will find a place.

I guess we will need to create a 'Tips and Tricks' section.

Gergo Erdosi
Joomla! Virtuoso
Joomla! Virtuoso
Posts: 4031
Joined: Sat Nov 11, 2006 9:34 pm
Location: Hungary

Re: Display name instead of username in Who is online module

Post by Gergo Erdosi » Mon Jul 14, 2008 8:50 am

I added it, can be found here:
http://docs.joomla.org/Display_name_ins ... ine_module

I think creating a Tips and Tricks category would be a good idea, maybe with some subcategories (the number of the tricks will be large in time...)

User avatar
brad
Joomla! Master
Joomla! Master
Posts: 13272
Joined: Fri Aug 12, 2005 12:38 am
Location: Australia
Contact:

Re: Display name instead of username in Who is online module

Post by brad » Mon Jul 14, 2008 9:16 am

erdsiger wrote:I added it, can be found here:
http://docs.joomla.org/Display_name_ins ... ine_module

I think creating a Tips and Tricks category would be a good idea, maybe with some subcategories (the number of the tricks will be large in time...)
I was thinking the same thing.. I will talk to the Documentation team about that.. BTW did you see this: http://community.joomla.org/core-team-b ... ricks.html


Locked

Return to “Submit Your Suggested Tips & Tricks to Docs.joomla.org now please.”