forked from bcit-ci/CodeIgniter
-
Notifications
You must be signed in to change notification settings - Fork 26
layout library
World Wide Web Server edited this page Jul 4, 2012
·
29 revisions
This is a cake-like layout/view system...
The Class File: (/application/libraries/Layout.php)
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Layout {
var $obj;
var $layout;
function Layout($layout)
{
$this->obj =& get_instance();
$this->layout = $layout;
}
function view($view, $data=null, $return=false)
{
$data['content_for_layout'] = $this->obj->load->view($view,$data,true);
if($return)
{
$output = $this->obj->load->view($this->layout,$data, true);
return $output;
}
else
{
$this->obj->load->view($this->layout,$data, false);
}
}
} ?>
In Your Controller:
Place this in the Controllers Parent Constructor:
$this->load->library(‘layout’, ‘layout_main’);
Place this in the Controllers Methods:
$this->layout->view('/shop/view_cart', $data);