Cmenu

Hello to everyone.

Somebody could help me with this problem.

I have a CMenu, and in one of the options of the menu i want to redirect my page to another one in the same project but this in this new page i had another main.

I try creating a new action in my controler:


$this->redirect('/index2');

but it has the next error "Unable to resolve the request "index2" ".

I don’t know if in my CMenu the item has the option to redirect or i need to do something else.

In other words I have this:

This is my CMenu in /protected/views/layout/main




<div id="mainmenu">

		<?php $this->widget('zii.widgets.CMenu',array(

			'items'=>array(

				array('label'=>'Nuevo Servicio', 'url'=>array('/servicios/create'), 'visible'=>!Yii::app()->user->isGuest ),

				array('label'=>'Reportes', 'url'=>array('/site/index'), 'visible'=>!Yii::app()->user->isGuest),

				array('label'=>'Busqueda', 'url'=>array('/site/contact'),'visible'=>!Yii::app()->user->isGuest),

				array('label'=>'Admin', 'url'=>array('/site/menuadmin'),'visible'=>Usuarios::isAdmin()),

				array('label'=>'Cerrar Sesion', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest),

				//array('label'=>'Login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),

				

			),

		)); ?>

	</div><!-- mainme



In the "Admin" option i want to redirect to another page with a similar menu with other options.

I hope to be clear, and if someone knows the topic i need to read or the solution please tell me, I’d appreciate it.

if i write wrong excuse me, english is not my natural language.

Thanks

create two layouts one for admin and another for users and use users layout when is user is not an admin so that you can have different layout with different menu otherwise separate your application into frontend and backend here frontend for normal users and backend for admins

Now i have the two layouts, but i don’t know how to show each one when the user or the admin login. Thats the real problem.

The item “Admin” it’s only visible to the admin and when he clicks that i want to redirect to another layout

in controller beforeAction() check the user like this




public function beforeAction($action)

{

if(Yii::app()->user->name==='admin')

 $this->layout='//layouts/admin-layout';

else

 $this->layout='//layouts/user-layout';

return true;

}