model to view

hi im new to yii.

I have a method in the model LoginForm:

private $_lastLogin;


public function getLastLogin(){

            return $this->_lastLogin;

            

           

        }

Now in view index.php i have




<?php if(!Yii::app()->user->isGuest):?>

<p>

   You last logged in on <?php echo date( 'l, F d, Y, g:i a', Yii::app()->user->lastLoginTime ); ?>.	

</p>

<?php endif;?>

How to include in the if the checking of something in the variable of the method?

I have to do something thru the controller?

Your question is not clear to me. I think you are changing the Yii testdrive code. In that sample code, you don’t use database or any other storage to store username/password, but an array containing them. In that sample, you cannot save save the last login time, unless you store it in a cookie, or something like that.

well think like it’s just a variable,a boolean for example.How to display or not something in the view according this variable?

To access that variable, first you need to pass the $model variable to the view:


$this->render('view_file',array('model'=>$model));

and in the view file, access it like this:


<?php print $model->lastLogin ?>

well in that case i have always to use the controller ,right?