Yii Framework Forum: Satu Controller dua Layout.... - Yii Framework Forum

Jump to content

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

Satu Controller dua Layout.... Rate Topic: -----

#1 User is offline   omarxp 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 12-February 10
  • Location:Yogyakarta

Posted 24 March 2010 - 12:12 AM

tolong, sya mw bikin 2 tampilan, misal user biasa masuk layout umum, kalo udah admin masuk layout server tp di satu controller.

sya tambahin script ini di controller blm bisa :

if (Yii::app()->user->IsGuest)
{
public $layout = 'umum';
}
else
{
public $layout = 'server';
}

muncul error :

Parse error: parse error, expecting `T_FUNCTION' in

mhon bimbingannya, trims.
0

#2 User is offline   Dan Din Dun 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 77
  • Joined: 09-February 10

Posted 24 March 2010 - 12:15 PM

View Postomarxp, on 24 March 2010 - 12:12 AM, said:

tolong, sya mw bikin 2 tampilan, misal user biasa masuk layout umum, kalo udah admin masuk layout server tp di satu controller.

sya tambahin script ini di controller blm bisa :

if (Yii::app()->user->IsGuest)
{
public $layout = 'umum';
}
else
{
public $layout = 'server';
}

muncul error :

Parse error: parse error, expecting `T_FUNCTION' in

mhon bimbingannya, trims.


coba:

Class ApaGitu extends Controller {
public $layout;

....

if (Yii::app()->user->IsGuest)
	{
		$this->layout = 'umum';
	}
	else
	{
		$this->layout = 'server';
	}
...
}

Thanks and Kind Regards
------
DanDinDun
0

#3 User is offline   omarxp 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 12-February 10
  • Location:Yogyakarta

Posted 24 March 2010 - 10:05 PM

udah bisa, tp logikanya di layout utama (biasanya main.php)

if (Yii::app()->user->IsGuest)
{
tampilan untuk tamu biasa
}
else
{
tampilan untuk admin
}

makasih Dan Din Dun.
0

#4 User is offline   rifqi 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 04-November 08

Posted 30 March 2010 - 11:07 PM

Maksudnya beginikah Bro?
if (Yii::app()->user->IsGuest) 
{    
   Yii::app()->layout = 'umum'; 
} else {    
   Yii::app()->layout = 'server'; 
}

0

Share this topic:


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

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