Skip to content

Instantly share code, notes, and snippets.

@turntayble81
Created August 30, 2011 16:37
Show Gist options
  • Save turntayble81/1181311 to your computer and use it in GitHub Desktop.
Save turntayble81/1181311 to your computer and use it in GitHub Desktop.
<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
class Layout
{
var $obj;
var $layout;
function Layout($layout = "layout/main")
{
$this->layout = $layout;
$this->obj =& get_instance();
$this->obj->load->model("db/labels_db_model");
$this->segmentArr = $this->obj->uri->segment_array();
if(isset($this->segmentArr[1])) {
$this->label = $this->obj->labels_db_model->getLabelBasicDetails($this->segmentArr[1]);
if($this->label) {
$this->label_id = $this->label->id;
}
}
}
function setLayout($layout)
{
$this->layout = $layout;
}
function view($view, $data=null, $return=false)
{
$loadedData = array();
if($this->layout == "layout/main" && isset($this->label_id)) {
$loadedData['label_styles'] = $this->obj->labels_db_model->getLabelAppearance($this->label_id);
}
$loadedData['content_for_layout'] = $this->obj->load->view($view,$data,true);
if($return)
{
$output = $this->obj->load->view($this->layout, $loadedData, true);
return $output;
}
else
{
$this->obj->load->view($this->layout, $loadedData, false);
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment