loadLayout Method

This loadLayout method will be loaded a layout file or view component that file relatives in current theme into view buffer.

Basic Usage

Here is the basic usage of loadLayout method.

$this->loadLayout(string $layout [, array $data = array()]): $this

Parameters

This method has 1 required parameter and 1 optional parameter.

$layout

The $layout value is string name of a file relatives to current theme.

Layout Requirements

The valid layout should only put inside page directory of the current theme.

app/
└── view/
  └── THEME_NAME/
    └── page/
      └── [LAYOUT_FILENAME].php

Example

Here is the example for loadLayout method:

<?php
class Blog extends SENE_Controller {
  public function __construct(){
    parent::__construct();
    $this->setTheme('front');
  }
  public function index(){
    $data = array();
    $data['example'] = 'this is example';
    $this->setTitle('Blog home');
    $this->putThemeContent("blog/home",$data);
    $this->putJsContent('blog/home_bottom',$data);
    $this->loadLayout('col-1',$data);
    $this->render();
  }
}

So, the front theme and col-1 layout should be existed on the directory structure.

app/
└── view/
  └── front/
    └── page/
      └── col-1.php

Info

The putThemeContent, putJsContent, and render method(s) has ability for buffered the html view.

Layout Naming Tips

If you confused how to decided the name of a layout, here is the tips with its filename:

  • col-1.php is for a page with one column.
  • col-2-left.php is for a page splitted by two column, and the menu are on left.
  • col-2-right.php is for a page splitted by two column, and the menu are on right.
  • col-3.php is for a page splitted by three column.
  • login.php the special layout for login.
  • homepage.php the special layout for homepage.