How to make a login fields on page header?

I managed to setup the simpleLogin extension (http://www.yiiframework.com/extension/simplelogin/) to my toy application.

Next, I want to move the login fields(account name, password, and remember me) to the page header. Honestly, I have no idea where to start, since there is no manual or tutorials on this topic. As a beginner, I can only do thing which has tutorials:) What is the best way to accomplish this? Is it using CPortlet or CWidget? How?

Is there any similar demo? I tried to read the Chive open source project(https://launchpad.net/chive), but was depressed by its complexity, how a human can do that:)~

Please advise! Thank you!

Nicolas

The layout (containing the header) is in the file protected/views/layout/main.php.

Place the login widget in the proper part of header.

I understand this.

Place the login widget in the proper part of header.

I don’t understand this. Where is the login widget? I think I need to make this widget right?

There’s no widget in the extension. You’ll need to make one if you want it.

See how to place the fields in the "login" view, shipped with the extension.

Read the guide http://yiiframework.com/doc/guide/ on how to work with forms and how to create the widget. Post here if you need further help.

Thanks! Let me experiment it this weekend!

Glad to help. Please let us know if you had success :)

Hello,

I’m a newbie to YII. The last week i build some lowlevel app pages which are working well.

Now i’m trying to add login fields to the header of the application.

I’m using the demo application of YII 1.1.1. and tried to copy the login widget code (see below) from the demo-login page to the main-page that includes the header ( /protected/views/layouts/main.php ), but this gives an error.




<div id="login_head">

	<div class="form">

		<?php $form=$this->beginWidget('CActiveForm', array(

			'id'=>'login-form',

			'enableClientValidation'=>true,

			'clientOptions'=>array(

				'validateOnSubmit'=>true,

			),

		)); ?>

			

		<?php echo $form->textField($model,'username'); ?>

		<?php echo $form->passwordField($model,'password'); ?>

		<?php echo $form->checkBox($model,'rememberMe'); ?>

		

		<?php echo CHtml::submitButton('Login'); ?>

		

		<?php 

			$this->endWidget(); 

		?>

	</div>

</div>



Can you post a guide how to add a login (and logout) to the header?

Unfortunately @Nettrinity didn’t add his solution to this forum.

Regards,

Guido Bushwacka

The Netherlands

it seems no bad.

how’s error?

did you set $model in the action method of controller?

Have your widget (or portlet) check first if the current user guest. If so, display a login form, view of which may reside inside your portlet.

It would help you a lot by reading further on the sample portlets of the blog tutorial. Those are excellent examples which should be able to provide you with base code for your login portlet.

@bumslayer - Which blog examples do you refer to? Do you have a link?

Thanks,

Guido

Building a Blog System Using Yii - The complete code examples are also shipped with the framework itself if you download it.

Great, i will check this out!

Thanks!