Skip to content

Instantly share code, notes, and snippets.

@phawk
Created January 14, 2012 12:06
Show Gist options
  • Save phawk/1611188 to your computer and use it in GitHub Desktop.
Save phawk/1611188 to your computer and use it in GitHub Desktop.
<?php
class MY_Controller extends CI_Controller
{
public $data = array(); // Array to store data - passed to views.
protected $view_path = null; // Here to overide the view path if needed.
protected function __construct()
{
parent::__construct();
}
protected function render()
{
if( is_null( $this-&gt;view_path ) )
{
$view_uri = $this-&gt;router-&gt;fetch_class() . &#39;/&#39; . $this-&gt;router-&gt;fetch_method();
}
else
{
$view_uri = $this-&gt;view_path;
}
// Auto write the view, and pass in the data object.
$this-&gt;template-&gt;write_view( &#39;content&#39;, $view_uri, $this-&gt;data );
$this-&gt;template-&gt;render();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment