Book Image

Yii Project Blueprints

By : Charles R. Portwood ll
Book Image

Yii Project Blueprints

By: Charles R. Portwood ll

Overview of this book

Table of Contents (15 chapters)
Yii Project Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Displaying and managing content


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('*'),
      ),
   );
}

Rendering the...