When you load any view inside your website you should always have an object named $viewer().
Here are some useful things you can find out in your view using the viewer object;
Get the current viewier’s Id
$this->viewer()->getIdentity(); |
Get the current viewier’s name
$this->viewer()->getTitle(); |
Get the current viewier’s profile URL
$this->viewer()->getHref(); |
Check if current user is an admin (return is either 1 or 0, true or false)
$this->viewer()->isAdmin(); |
If you want to be able to do the same thing within your controller rather than your view you can also use
Get current viewer’s identity
Engine_Api::_()->user()->getViewer()->getIdentity(); |
On a side note if you ever need to know whats being loaded in your view just print_r out the view object. However I find it extremely useful to call get_class_methods() on the object so that you can see what you can do with it;
echo '<pre>'; print_r(get_class_methods($this->viewer())); echo ' |
‘;
(get rid of the backslash, had to include it to stop my pre tags messing up!