I’m using Symfony and sfDoctrineGuardPlugin.
How do I display, in a template, the username of the current user ?
I’ve tried $this->getUser()->getUsername(), but all I get is the error : “Call to undefined method sfPHPView::getUser.”
I’m trying to display the username in a layout.php, not in a particular module/template
In a template (view), use
$sf_user:For the username:
For the id:
Or, in an action (controller), you can do what you’re doing in your question:
and then
$usernamewill be available in your view template.See template shortcuts in the Symfony docs for other view variable shortcuts.