Page 1 of 1

Display name instead of username in Who is online module

Posted: Sun Jul 13, 2008 5:33 pm
by Gergo Erdosi
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.

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

Posted: Sun Jul 13, 2008 9:19 pm
by brad
How about putting this on docs.joomla.org ?

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

Posted: Sun Jul 13, 2008 9:41 pm
by Gergo Erdosi
It's okay for me, just I don't where exactly could I place this on docs.joomla.org...

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

Posted: Sun Jul 13, 2008 9:50 pm
by brad
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.

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

Posted: Mon Jul 14, 2008 8:50 am
by Gergo Erdosi
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...)

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

Posted: Mon Jul 14, 2008 9:16 am
by brad
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