The Joomla! Forum ™



Forum rules


Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.



Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Wed Sep 05, 2007 12:09 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Jul 13, 2006 6:08 am
Posts: 21
Hi all, still reasonably new to the template capabilities...

Is it possible to get a users name in a template as opposed to a module etc?  What I have is a nav bar at the top that says "Welcolme guest" or "Welcolm xxx" depending on their login status.

Is it possible to determine this from the template itself, or do I need to write a simple module/component to do it?


Top
 Profile  
 
PostPosted: Thu Sep 06, 2007 1:26 pm 
User avatar
Joomla! Ace
Joomla! Ace

Joined: Thu Aug 18, 2005 8:57 am
Posts: 1376
Location: Shrewsbury, Shropshire, United Kingdom
You have access to pretty much the whole API from within the template.  To get the username you can use this code:
Code:
<?php
$user=& JFactory::getUser();
$username = $user->guest ? 'guest' : $user->username;
?>


Regards,
Chris.

_________________
Joomla Leadership Team - Production Working Group

Joomla Web Services http://www.kickstarter.com/projects/964120480/joomla-web-services
Lion Coppice http://www.lioncoppice.org


Top
 Profile  
 
PostPosted: Thu Sep 06, 2007 2:16 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Jul 13, 2006 6:08 am
Posts: 21
Thanks Chris!


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 



Who is online

Users browsing this forum: No registered users and 7 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group