Fixed Header And Footer In Yii

I have a login form in my header section of the website. If user is logged in than insted of the login form user profile details will be shown. The question is how to separate header footer and content into different views and call them from one controller? Or maybe there is another solution…Thanks for help.

You can separate header,footer and contents using layouts.Create a folder name layouts inside views.

Please go through this to have a detailed understanding.

http://www.larryullman.com/2012/05/16/working-with-layouts-in-yii

sir! thanks for the help… :)

You could also use if…then…else statements:




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

   // Show Login form

<?php else: ?>

   // show profile details

<php endif; ?>



I am using a CMenu in the upper right to show login links to guests or a link to edit logged in users profile using the ‘visible’=> of the ‘items’ array.

Just some other thoughts ::)