I’m totally new to YII, so this question might be quite silly, but where do I change the default layout for static pages? I know that with dynamic pages I do it in controller’s action… Is there any method I have to overwrite for the static pages, so I can chose a different layout?
It’s an old thread but I came across this issue and want to help others who might have the same problem.
In order for the static pages to use the same layout that the dynamic ones are using, do this:
Edit SiteController.php and add the following code in the SiteController
class SiteController extends Controller
{
/**
* @var string the default layout for the views. Defaults to '//layouts/column2', meaning
* using two-column layout. See 'protected/views/layouts/column2.php'.
*/
public $layout='//layouts/column2';
Where column2 refers to the column2.php file which is located inside the /themes/MyTheme/layouts/ directory.
Yes it’s an old thread but it came up when I was searching for a solution to a problem.
I have a controller that deals with various profiles, these profiles were imported from another system, along the way I made notes for my client and I wanted a static view to allow the client to refer to this in case people got lost during the transition.
So I put this code in my ‘profile’ controller.
public function actions()
{
return array(
// page action renders "static" pages stored under 'admin/views/profile/pages'
// They can be accessed via: index.php?r=profile/page&view=FileName
'page'=>array(
'class'=>'CViewAction',
'layout'=>'//layouts/admin1col'
),
);
}
And in the default view I put this CMenu array. Second entry is the link to the static view.
The view is called import_notes.php and placed in /views/profile/pages