-
Book Overview & Buying
-
Table Of Contents
Yii Application Development Cookbook - Second Edition - Second Edition
One of the Yii features you can use in your views is clips . The basic idea is that you can record some output and then reuse it later in a view. A good example would be defining additional content regions for your layout and filling them elsewhere.
Set up a new application using yiic webapp.
For our example, we need to define two regions in our layout: beforeContent and footer. Open protected/views/layouts/main.php and insert the following code line just before the content output (<?php echo $content; ?>):
<?php if(!empty($this->clips['beforeContent'])) echo $this->clips['beforeContent']?>
Then, insert the following into <div id="footer">:
<?php if(!empty($this->clips['footer'])) echo $this->clips['footer']?>
That is it! Now, we need to fill these regions somehow. We will use a controller action for the beforeContent region. Open protected/controllers/SiteController.php and add the following code to actionIndex:
$this...
Change the font size
Change margin width
Change background colour