Can We Create Sub Folder For Controller And View ?

Dear all,

in view of yii,we create folder of view by controller name.However, I want to create 2 sites of view: admin and user, is there any ways can do like this:

controller name:ServicesController

for the view, we usually create


views/services/index.php

,but can I create view like this:


views/users/services/index.php

thanks

Check the URL Management section in the Guide..

You can use modules or override the getViewPath() method of your basecontroller (=Controller.php)




class Controller extends CController {

   public $viewSubDir;


        public function getViewPath()

	{

              if(empty($this->viewSubDir)

                 return parent::getViewPath()

              else

              {

	

               if(($module=$this->getModule())===null)

			$module=Yii::app();

		return $module->getViewPath().DIRECTORY_SEPARATOR.$this->viewSubDir.DIRECTORY_SEPARATOR.$this->getId();

              } 


	}


   ...

}




In your ServiceController




class ServiceController extends Controller 

{

   public $viewSubDir = 'users';


    ...




}




Or you can set the viewSubdir in the actions ‘on the fly’ before calling render.





  public function actionXY() 

  {

      ...

      $this->viewSubDir = 'admin';

      $this->render(...)

  }




Use url manager and module generator