Hello, I'm new to Yii - and to frameworks. I'm trying to extend the blog tutorial so that it will handle multiple blogs. I'd like to set up a filter such that, if $_GET['blog'] is empty, it will redirect the user to a page that lists the blogs.
However, I'm getting a "filter invalid" error.
Since my filter should be accessible from both the Post and Comment classes, I created a filter class - BlogFilter, which is saved in a file: /protected/filters/BlogFilter.php
Here's the code:
<?php
class BlogFilter extends CFilter
{
protected function preFilter($filterChain)
{
// logic being applied before the action is executed
if(empty($_GET['blog'])) header('Location: /yblog/index.php?r=blog');
exit;
return false; // false if the action should not be executed
}
}
?>
and here's my filters method in PostController.php:
<?
public function filters()
{
return array(
'application.filters.BlogFilter',
'accessControl', // perform access control for CRUD operations
);
}
?>
shouldn't that work?