Yii create BaseController for Layout -


i reading link "how implement multiple page layouts in application" easy until says: use controller layout , have better create basecontroller in protected/components/basecontroller.php ,it easy , created php file content:

abstract class basecontroller extends ccontroller {     public $crumbs=array();     public $portlets=array();     public $portlets2=array(); } 

and put these lines main.ph in components section:

    'basecontroller'=>array(             'class'=>'application.components.basecontrollert',         ),   

and when use in layout:

$this->portlets

it return

property "homecontroller.portlets" not defined.

which means inside main controller variable.

how solve problem ?

  • all layout code written according link link.

you forgot controllers must extends class.

read : http://www.yiiframework.com/wiki/28/#hh1

then can derive base class each individual concrete controller class

you have modify controllers :

class mycontroller extends basecontroller { ..... } 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -