how to show twitter bootstrap model for unauthenticated users.

hi All,

I have created blog posting sample and try to add new features. Simple use case: I have allow users to comment and add like to post. For this two action, if user not logged in then i want to show twitter bootstrap model and ask them to login OR if new user ask them to signup

In my config/main.php, I have added these items.




'components'=>array(

'behaviors' => array(

			'onBeginRequest' => array(

				'class' => 'application.components.RequireLogin'

			)

		),

		//

		'user'=>array(

			// enable cookie-based authentication

			'class' => 'WebUser',

			'allowAutoLogin'=>true,

			'loginUrl'=>array('/intro/index'),

		),

),



Under components/RequireLogin.php




<?php

class RequireLogin extends CBehavior

{

	public function attach($owner)

	{

		$owner->attachEventHandler('onBeginRequest', array($this, 'handleBeginRequest'));

	}

	public function handleBeginRequest($event)

	{

		if (Yii::app()->user->isGuest && !in_array($_GET['r'],array('/intro/index'))) {

			Yii::app()->user->loginRequired();

		}

	}

}

?>



In my components/webuser.php




<?php

 

// this file must be stored in:

// protected/components/WebUser.php

 

class WebUser extends CWebUser {

 

 

	 public function loginRequired() {

       

		// Need to render twiiter model

    }


}

?>



here, in this WebUser class, how do i render my view file. please help me.

Thanks.

I would suggest using the WebUser class in a widget in the view file, instead of rendering view file from the WebUser class.

Can u give some sample code to this problem? Breaking my heads on this issue? please

Take a look at The Yii Blog Tutorial, the chapters under "Portlets".

CPortlet is a subclass of CWidget, so creating portlets is the same as creating widgets.