obtain user id in main.php

Hello folks, is there any way i can get the id of a user in layouts/main.php in my Cmenu? In my Cmenu i have


array('label'=>'My Account', 'url'=>array('/user/update/25'), 'visible'=>!Yii::app()->user->isGuest)

which is visible only when a user logs in. I cannot use the id 25 since it will be different when another user logs in so i would like to know how can i get the id of the user so that when i click on My Account, the appropriate id is used?

You can use Yii::app()->user->id, this should return the username of the user.

You can eather rewrite the loadModel in the user controller in order to use the username (so you will have an url like /user/update/Rahul) or use the username for get the user id:




$user= User::model()->findByAttributes(array('username'=>Yii::app()->user->id));


array('label'=>'My Account', 'url'=>array('/user/update/', 'id'=>$user->id), 'visible'=>!Yii::app()->user->isGuest)



Thanx it works!