Switch layout

Hi all !

How can I switch the whole application to another design?

I have two main designs. The user should be able to switch between the two.

I guess I need to modify the Application object. Something in that flavour?

Yii::App()->layout = 'myLayout'

Yes, that's right. You can do it in app config.

You may also consider using theme.

But I need to modify the design dynamically :)

Does Yii::App() return the current instance of the application object?

Ok… in the Doc, returns the application singleton.

Curious though, that the action to change the layout doesn't work.

It should work. you need to make sure you call this before render().

Ok, I may have done something else wrong.

Thank you very much Qiang.

The App() object remains unchanged…

public function actionLayoutChange() {

		Yii::App()->layout = 'master2_map';



That only changed the layout for THAT REQUEST.  When you redirect you move to a different request.  You need to create a mechanism to remember the layout through different requests.

Hi Jonah, thanks ! (of course, I'm stupid…)

Trying out :)