How To Set Login Page As My Main Page.?

Hi,

in my application , i want that login page is my main home page…menu and all things should not display.

after i login successfully, it will display all menu and stuff…

what are the steps for do that…

Please help me…

Thanks in Advance.

With Regards,

Janvi

Write script your menu or whatever between this.

eg. -


if !(Yii::app()->user->isGuest):


          //stuff

          //stuff

          //stuff


endif;

the stuff display only to logged user.

Exclamation mark goes inside the brackets.

Hello Sir,

i didnt get exactly what u want to say…can u please elaborate…

Thanks,

Hello Sir,

i have change the condition as u have mentioned above…and its works…

Thanks for giving ur precious time…

With Regards,

Janvi

Hello Bizley Sir,

i have used that condition in my main.php file as Suthat Sir mentioned, and yeah its works…

THank you so much…

With Regards,

Janvi

Ok i understand -

first set login page in config file -


// application components

'components'=>array(

	'user'=>array(

		  'loginUrl' => array('site/login'),

	 ),

 ) 

and define the access rules in your Controller like this -


 public function accessRules()

	{

		return array(

		

		       array('allow',

				'actions'=>array(

				                 'login'		       

				                ),

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

			),

			

			array('allow',

				'actions'=>array(

				                 'index', 'error', 'logout'

				                ),

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

			),

			array('deny',  // deny all users

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

			),

		);

	}

you need to set only login page in first array, so un-looged user auto redirect to login page and after login user can access index, logout etc. page so you need to set or define in second array.

Your welcome miss :)

Hey Janvi,

Set SiteController and actionLogin() as default controller which will redirect to login page upon accessing the site.

Code goes as below.

webroot/protected/config/main.php




  return array(

    'DefaultController'=>'site/login',

);