Skip to content

Instantly share code, notes, and snippets.

@walesmd
Created April 26, 2009 19:57
Show Gist options
  • Save walesmd/102147 to your computer and use it in GitHub Desktop.
Save walesmd/102147 to your computer and use it in GitHub Desktop.
<?php
// application/libraries/MY_Controller.php
class MY_Controller extends Controller {
var $partial = 'debug/echo';
function MY_Controller() {
parent::Controller();
$this->_get_partial();
$this->_get_model();
}
function _get_partial() {
$uri = $this->router->class . '/' . $this->router->method;
if (is_file(realpath(dirname(__FILE__) . '/../views/' . $uri . EXT))) {
$this->partial = $this->router->class . '/' . $this->router->method;
}
}
function _get_model() {
$uri = substr($this->router->class, 0, -1);
if (is_file(realpath(dirname(__FILE__) . '/../models/' . $uri . EXT))) {
$this->load->model($uri);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment