این کلاس برای Master Page ... کسایی که با Yii کار کردن متدهای render و renderPartial رو یادشونه اولی با layout دومی بدون layout عمل میکنه :

<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
/*
* Author : Arash Aryani
* Time : 2014/11/23
*/
class Template{
private $fields;
public function __construct(){
$this->fields = array(
'CI' => null,
'layout'=>null,
'title' => null
);
$this->fields['CI'] =& get_instance();
}
public function __set($key , $value){
if(array_key_exists($key,$this->fields)){
$this->fields[$key] = $value;
}
}
private function loadView($view , $params = array() , $useLayout = false){
$content = $this->fields['CI']->load->view($view,$params,true);
if($useLayout){
$this->fields['CI']->load->view('layouts/'.$this->fields['layout'] , array('content'=>$content,'title'=> $this->fields['title']));
}else{
echo $content;
}
}
public function render($view , $params = array()){
$this->loadView($view,$params,true);
}
public function renderPartial($view , $params = array()){
$this->loadView($view,$params);
}
}



طزر استفاده :

در پوشه view یک پوشه بنام layouts بسازید و layout های خودتون رو درونش قرار بدین ، مثلا" فرض کنید layout من home باشه و میخوام view مربوط به Controller همون welcome رو نمایش بدم :

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Welcome extends CI_Controller {

/**
* Index Page for this controller.
*
* Maps to the following URL
* http://example.com/index.php/welcome
* - or -
* http://example.com/index.php/welcome/index
* - or -
* Since this controller is set as the default controller in
* config/routes.php, it's displayed at http://example.com/
*
* So any other public methods not prefixed with an underscore will
* map to /index.php/welcome/<method_name>
* @see http://codeigniter.com/user_guide/general/urls.html
*/
public function index()
{

$this->template->layout = 'home';
$this->template->render('welcome/site');
}
}

/* End of file welcome.php */
/* Location: ./application/controllers/welcome.php */


حالا اگه فقط میخواین خود view رو نمایش بدین بدون layout کافیه فقط بنویسید :
$this->template->renderPatial('welcome/site');

برای قرار دادن title :
$this->template->title = 'test';