简体   繁体   中英

Joomla - Show logged username in top menu

How can I show the logged username in the top menu of Joomla. I have the following code but don't know where to insert it.

$user =& JFactory::getUser(); echo $user->name;

The login module can display a greeting. You just have to go to Extensions > Module Manager > Login whatever you have the login module display name

https://docs.joomla.org/Customising_the_Login_Form_module

First check which theme currently activated in your joomla project.

For eg If currently default theme "protostar" in joomla 3.x activated then

  1. Go to "\\PROJECT_FOLDER\\templates\\protostar" .

  2. Open index.php file.

  3. Put code after <div class="body"> tag start and add your code in your desire position.

Use below code.

<?php
$user =& JFactory::getUser(); 
echo $user->name;
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM