Now that Yii knows how to route our content, we can begin work on displaying and managing it. Begin by creating a new controller called ContentController
in protected/controllers
that extends CMSController
. Have a look at the following line of code:
class ContentController extends CMSController {}
To start with, we'll define our accessRules()
method and the default layout that we're going to use. Here's how:
public $layout = 'default'; public function filters() { return array( 'accessControl', ); } public function accessRules() { return array( array('allow', 'actions' => array('index', 'view', 'search'), 'users' => array('*') ), array('allow', 'actions' => array('admin', 'save', 'delete'), 'users'=>array('@'), 'expression' => 'Yii::app()->user->role==2' ), array('deny', // deny all users 'users'=>array('*'), ), ); }