Allow users to view posts without loged in

Hi,

I am not much familiar with Yii, even though i am learning Yii framework. And now i have a problem to view the posts without loged-in. It will automatically redirect to login page. I have clearly added the access rules in my controller. And this is placed under the directory protected/modules/blog. Is this the problem? Modules won’t work without login? i have a lot of doubts like this. And i am not getting any solution for this.

Here is the access rules of my controller file.




	public function accessRules()

	{

		return array(

			array('allow',  // allow all users to access 'index' and 'view' actions.

				'actions'=>array('index','view'),

				'users'=>array('*'),

			),

			array('allow', // allow authenticated users to access all actions

				'actions'=>array('update','create'),

				'users'=>array('@'),

			),

			array('deny',  // deny all users

				'users'=>array('*'),

			),

		);

	}




Can anyone help me to find a solution for this issue? if i am wrong in any of the procedures please correct me.

Thanks in advance…

does index page shows normaly? are you sure the link of the post title (if i got you right) points to the view action of blog module?

give more details… atleast the URL you are trying to access.

First of all thank you StasuSS and Mukesh!

Here i am listing the flow of the pages, This is Town page based on a selection of a town with id 10

http://localhost/myapp/town/view/id/10 from this page i am trying to open the next page as http://localhost/myapp/blog/activity and this blog directory located under protected/modules/ directory. Also there is no problem for the town page, to see the view page.

The problem happening between the town page to blog/activity page. While we open the activity page, if we didn’t logged-in, suddenly it will redirect to login page, its url is http://localhost/myapp/user/user/signin, a white-box login form.

And rest of the pages, i didn’t feel the login restriction problem, if its required user login for posting new topic in blog, it will restrict the user to login first and then create a post.

Will this help you to identify the issue? please give your valuable feedback.

to access http://localhost/myapp/blog/activity, you will have to change the access rules of activityController within your blog module. Can you give (copy-paste here) the access rules in activityController.php?

Here is the activity controller class access rules,




class ActivityController extends Controller

{


	public $layout='column2';


	/**

	 * @var CActiveRecord the currently loaded data model instance.

	 */

	private $_model;


	/**

	 * @return array action filters

	 */

	public function filters()

	{

		return array(

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

		);

	}


	/**

	 * Specifies the access control rules.

	 * This method is used by the 'accessControl' filter.

	 * @return array access control rules

	 */

	public function accessRules()

	{

		return array(

			array('allow',  // allow all users to access 'index' and 'view' actions.

				'actions'=>array('index','view'),

				'users'=>array('*'),

			),

			array('allow', // allow authenticated users to access all actions

				'actions'=>array('update','create'),

				'users'=>array('@'),

			),

			array('deny',  // deny all users

				'users'=>array('*'),

			),

		);

	}



And here is the town controller class access rules




        public function accessRules()

        {

                return array(

                        array('allow',  // allow all users to perform 'index' and 'view' actions

                                'actions'=>array('index','view'),

                                'users'=>array('*'),

                        ),

                        array('allow', // allow authenticated user to perform 'create' and 'update' actions

                                'actions'=>array('create','update'),

                                'users'=>array('@'),

                        ),

                        array('allow', // allow admin user to perform 'admin' and 'delete' actions

                                'actions'=>array('admin','delete'),

                                'users'=>array('admin'),

                        ),

                 );

        }