yangruiyou85 / yiidoc

Automatically exported from code.google.com/p/yiidoc
0 stars 0 forks source link

Default layout for a module or controller code exemple #39

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I see a problem here because the fact that nothing is illustrated with a
simple piece of code on how to use CController::layout. not in a controller
not in a module, but here's a piece of code that can be useful as a solution:

Code for a module
public function init()
    {
        .........       
        //set the default layout to 'main' located in
        // moduleId/views/layout/main.php
        $this->layout = "main";
                .........
    }

Code for a controllerAction

<?php

class DefaultController extends CController
{
    public function actionIndex()
    {

        $this->layout = "main";
        $this->render('index');
    }
}

and maybe for the whole controller with a beforeFilter.

Original issue reported on code.google.com by webscri...@gmail.com on 19 Oct 2009 at 9:39

GoogleCodeExporter commented 9 years ago

Original comment by alexander.makarow on 27 Dec 2009 at 9:58

GoogleCodeExporter commented 9 years ago
In the new skeleton code in 1.1.1, you will see how to set layout.

Original comment by qiang.xue on 17 Feb 2010 at 10:14