Filter is invalid exception

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?

For class based filter you should use the following format:

array('application.filters.FilterClass'),

so in your case, it should read:

 public function filters()


   {


      return array(


        array( 'application.filters.BlogFilter'),


         'accessControl', // perform access control for CRUD operations


      );


   }

yes, ok - thanks, that's it.

and… for the record, my filter had a minor error in its code - the exit stopped execution whether there was the required $_GET value present or not.  This works:

<?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');


			return false; // stop action


		} else {


			return true; // continue through chain


		}


    }


}





?>