O'Reilly logo

Yii Project Blueprints by Charles R. Portwood II

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Viewing and managing categories

Now, let's move to viewing and managing categories. As outlined previously, each category will be accessible via a dedicated route and will only display content within that category. We'll start by defining our default access rules and layout name in protected/controllers/CategoryController.php:

public $layout = 'default';

public function filters()
{
   return array(
      'accessControl',
   );
}

public function accessRules()
{
   return array(
      array('allow',
         'actions' => array('index', 'view', 'rss'),
         'users' => array('*')
      ),
      array('allow',
         'actions' => array('admin', 'save', 'delete'),
         'users'=>array('@'),
         'expression' => 'Yii::app()->user->role==2'
      ),
      array('deny',  // deny all users
         'users'=>array('*'),
      ),
   );
}

Viewing entries ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required