Custom header for landing page

I want different headers for my landing page and all other pages in my webapp. What is the best way to do this?

AS far as my understanding goes, the header and footer are loaded from the view/layouts/main.php, In my case since I am using a theme, it is loaded from themes/new/views/layouts/main.php

Now I want the header section for all my pages except the landing page, to use the header section as defined in the "main.php", however the landing page should have a different header. How should I do this? Should I use a render partial? And since I am Yii newbie, how should I do this?

Can I also use one of the other layouts files, column1.php or column2.php? And how?

I am not looking for extensive hand holding here. I just need a heads up, as to how people have implemented similar functionality.

  1. You should create a different layout (which you will use on the landing page) - call it whatever you want.php

  2. In your controller for the page that you want a different layout for (Homepage , So probably in SiteController actionIndex). Do $this->layout="layout created in point 1"

I tried doing this, but the page changes to a default controller, i think column1.php, maybe I am not linking it right.

I created a front.php file and stored it under /views/layouts, and also themes/new/views/layouts (as i am using a custom theme),

I added this to the index action of SiteController,


And the page changes to using the default controller. Any ideas what I am doing wrong?

Leave out ‘.php’ - you don’t use the extension when setting the layout. :)

Solved the problem after searching through a few forum post, regarding how to use $this->layout.

Thank you ykamakazi for your help, have been struggling with this since the morning. Saved a couple of hours for me.

Thanks, realised that after posting. Got the new layout file working now. :D