Development - Layouts

ApPHP Framework supports layouts for each separate template.

For each application you may define a default layout settings in configuration file. If no layout is defined as default the "default" name will be used.
return array(
    // Layout default settings  
    'layouts' => array(
        'enable' => array('frontend' => false, 'backend' => false), 
        'default' => 'default',			

Sometime we need to use more than one layout in selected template and we need some way to change a layout "on fly". For example we need different templates for Homepage, for Contact Us page, blog post pages etc. The symplest way to do this is to re-define it directly in constructor of appropriate controller.
class PagesController extends CController
    public function __construct()
You may also do this in each action separately:
class PagesController extends CController
    public function addAction()

    public function viewAction()

The common structure of the template directory with layouts looks like following:
Example of default.php file (template):
<!doctype html>
    <meta charset="UTF-8" />
    <meta name="keywords" content="<?= CHtml::encode($this->_pageKeywords); ?>" />
    <meta name="description" content="<?= CHtml::encode($this->_pageDescription); ?>" />
    <title><?= CHtml::encode($this->_pageTitle); ?></title>
    <base href="<?= A::app()->getRequest()->getBaseUrl(); ?>" />
    <?= CHtml::cssFile("templates/default/css/main.css"); ?>
    <?= CHtml::scriptFile('//'); ?>
    <?= CHtml::scriptFile('templates/default/js/main.js'); ?>
            <a href="index">Home</a>
        // Your layout content here
        <?= A::app()->view->getLayoutContent(); ?>
        <p class="copyright">Copyright © <?= date('Y'); ?> Your Site</p>
        <p class="powered"><?= A::powered(); ?></p>

The layout file looks like following:
<div class="row">
    <div class="col-lg-8">
        <?= A::app()->view->getContent(); ?>