On Sun, Jan 9, 2011 at 6:06 PM, cake-learner <[email protected]> wrote:
> How can i set up so that that variable can be referenced in the
> element?
>
> I have set up left_menu.ctp in the element and want to change the menu
> items depending on that what role the current user is. Where I can get
> the user object from the session so that user object is available in
> left_menu.ctp?
>
> I can go each controller to do this but since left_menu is displayed
> in the most of page I want to have one controller handle this.

In a view, element, or layout:

if ($session->read('Auth.User.role') == 'whatever')

In a controller:

if ($this->Auth->user('role') == 'whatever')

Adjust to your needs. Note that the Auth method is user (lowercase)
while the session key is User.

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to