Difference between revisions of "Display name instead of username in Who is online module"
From Joomla! Documentation
Line 1: | Line 1: | ||
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 | 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 | ||
− | + | <source lang="php"> | |
− | + | $query = 'SELECT DISTINCT a.username' . | |
− | + | ' FROM #__session AS a' . | |
− | + | ' WHERE client_id = 0' . | |
+ | ' AND a.guest = 0'; | ||
+ | </source> | ||
to | to | ||
− | + | <source lang="php"> | |
− | + | $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'; | ||
+ | </source> | ||
There is only one step left, open the /modules/mod_whosonline/tmpl/default.php file and at the bottom change | There is only one step left, open the /modules/mod_whosonline/tmpl/default.php file and at the bottom change | ||
− | + | <source lang="php"> | |
+ | <?php echo $name->username; ?> | ||
+ | </source> | ||
to | to | ||
− | + | <source lang="php"> | |
+ | <?php echo $name->name; ?> | ||
+ | </source> | ||
This trick was written for Joomla! 1.5. | This trick was written for Joomla! 1.5. | ||
[[Category:Tips and tricks]] | [[Category:Tips and tricks]] |
Revision as of 08:47, 14 July 2008
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
$query = 'SELECT DISTINCT a.username' .
' FROM #__session AS a' .
' WHERE client_id = 0' .
' AND a.guest = 0';
to
$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
<?php echo $name->username; ?>
to
<?php echo $name->name; ?>
This trick was written for Joomla! 1.5.