Skip to content

Instantly share code, notes, and snippets.

@sapphiriq
Created November 11, 2011 21:57
Show Gist options
  • Save sapphiriq/1359432 to your computer and use it in GitHub Desktop.
Save sapphiriq/1359432 to your computer and use it in GitHub Desktop.
<?php
protected function display($template = FALSE, $render = TRUE)
{
if ($template == FALSE)
{
// Delete package namespaces (e.g., App\Controllers)
$name = strtolower(get_class($this));
$name = implode(DS,array_slice(explode('\\', $name), 2));
$action = $this->request->get_action();
$tpl = APPPATH.'views'.DS.$name.DS.$action.'.php';
} else {
$template = str_replace('/',DS, $template);
$tpl = APPPATH.'views'.DS.$template.'.php';
}
if ( ! file_exists($tpl))
$this->response->error500();
// Render template
ob_start();
extract($this->_params);
include $tpl;
$yield = ob_get_clean();
include APPPATH.'views'.DS.'layouts'.DS.$this->layout.'.php';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment