Yii Framework Forum: Configuring Sitecontroller - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Configuring Sitecontroller making my webapp default to login instead of home Rate Topic: -----

#1 User is offline   ikotee 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 24-April 13

Posted 27 April 2013 - 09:34 AM

greetings all

I have read the manual apparently am missing some valid details-after hitting my head for so long, i figured perhaps someone out there has a handy solution. My problem simply is getting my application to authenticate users before access to any page including the home page. i followed larry's tutorial and read the documentation so i realise i need to setup a logincontroller and a view /login/index.php. so i copied all the codes from sitecontroller minus references to contact and about to login. added 'defaultController' =>'login'; in config/main but its not working except errors-

i figure i wont need to make so many changes to get my application to start firing from login. heres my code:


class LoginController extends SiteController
public $layout='/layouts/column1';

public function getPageTitle()
return 'Web-based pension pay system';
return ''.ucfirst($this->action->id).' Pensioner';

public function actionIndex()

public function actionError()
echo $error['message'];
$this->render('error', $error);

* Displays the login page

public function actionLogin()
$model=new LoginForm;

// if it is ajax validation request
if(isset($_POST['ajax']) && $_POST['ajax']==='login-form')
echo CActiveForm::validate($model);

// collect user input data
// validate user input and redirect to the previous page if valid
if($model->validate() && $model->login())
// display the login form

* Logs out the current user and redirect to homepage.
public function actionLogout()

} and heres my views

/* @var $this SiteController */
/* @var $model LoginForm */
/* @var $form CActiveForm */

$this->pageTitle=Yii::app()->name . ' - Login';


<p>Please fill out the following form with your login credentials:</p>

<div class="form">
<?php $form=$this->beginWidget('CActiveForm', array(
)); ?>

<p class="note">Fields with <span class="required">*</span> are required.</p>

<div class="row">
<?php echo $form->labelEx($model,'username'); ?>
<?php echo $form->textField($model,'username'); ?>
<?php echo $form->error($model,'username'); ?>

<div class="row">
<?php echo $form->labelEx($model,'password'); ?>
<?php echo $form->passwordField($model,'password'); ?>
<?php echo $form->error($model,'password'); ?>
<p class="hint">
Hint: You may login with <kbd>demo</kbd>/<kbd>demo</kbd> or <kbd>admin</kbd>/<kbd>admin</kbd>.

<div class="row rememberMe">
<?php echo $form->checkBox($model,'rememberMe'); ?>
<?php echo $form->label($model,'rememberMe'); ?>
<?php echo $form->error($model,'rememberMe'); ?>

<div class="row buttons">
<?php echo CHtml::submitButton('Login'); ?>

<?php $this->endWidget(); ?>
</div><!-- form -->

and the error
include(SiteController.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory

Will appreciate some help

#2 User is offline   jacmoe 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 3,317
  • Joined: 10-October 10
  • Location:Denmark

Posted 27 April 2013 - 10:05 AM

/* moved from Feature Requests */
"Less noise - more signal"

Share this topic:

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users