Revision #4 has been created by Maurizio Domba Cerin on Oct 27, 2012, 6:35:41 PM with the memo:
iIf you use yiic to generate webApplication there will
be
xists a layout
s di folder under the protected/views/, and the Controller class under protected/components which will
use by default
use these layouts files
.
aAll your controllers may extends the Controller base class directly or indirectly
.
pPlease look at th
isat class
, you may find this lines
:
```php
/**
* @var string the default layout for the controller view. Defaults to '//layouts/column1',
* meaning using a single column layout. See 'protected/views/layouts/column1.php'.
*/
*/
public $layout = '//layouts/column1';
/**
* @var array context menu items. This property will be assigned to {@link CMenu::items}.
*/
*/
public $menu = array();
/**
* @var array the breadcrumbs of the current page. The value of this property will
* be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}
* for more details on how to specify this property.
*/
*/
public $breadcrumbs = array();
```
these variables will be shared by all its subClasses (may be you
r whole XXXController of your project
) ). except the $layout variable the other two usually used to pass variables to layout files
:
```php
$this->breadcrumbs=array(
'Albums'=>array('index'),
'Manage',
);
$this->menu=array(
array('label'=>'List Album','url'=>array('index')),
array('label'=>'Create Album','url'=>array('create')),
);
```
iIf you use gii to generate crud functionality you may see such code in the top section of file (admin.php,
index.php,
create.php,
update.php,
view....). "$this" represent the current controller
, so "breadcrumbs" and "menu" are the member variables of controller and
it defined in "Controller" class
.
n
Now lets take look at layout file "column2":
```php
<?php $this->beginContent('//layouts/main'); ?>[...]
'links'=>$this->breadcrumbs,
)); ?><!-- breadcrumbs -->
<?php endif?>
..
```
so you can see the "$this->menu " and "$this->breadcrumbs" are assigned in view files (create.php, index.php, admin.php ....) ;[...]