janvimca571985
(janvimca571985@gmail.com)
September 11, 2014, 11:54am
1
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.
Bizley
(Bizley)
September 11, 2014, 12:04pm
3
Exclamation mark goes inside the brackets.
janvimca571985
(janvimca571985@gmail.com)
September 11, 2014, 12:07pm
4
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.
Hello Sir,
i didnt get exactly what u want to say…can u please elaborate…
Thanks,
janvimca571985
(janvimca571985@gmail.com)
September 11, 2014, 12:13pm
5
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.
Hello Sir,
i have change the condition as u have mentioned above…and its works…
Thanks for giving ur precious time…
With Regards,
Janvi
janvimca571985
(janvimca571985@gmail.com)
September 11, 2014, 12:15pm
6
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.
paul_po
(Paul Arockiyam)
September 11, 2014, 6:53pm
9
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',
);