Created
June 7, 2012 15:54
-
-
Save mathewpeterson/2889624 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MY_Controller extends CI_Controller | |
{ | |
/** | |
* Takes the method passed to it for the router | |
* and loads a header and footer for all controller methods | |
* automatically setting an id and class for CSS Scoping | |
* | |
* @param string $method | |
* @return null | |
* @author Kenny Meyers | |
*/ | |
public function _remap($method) | |
{ | |
if(method_exists($this, $method)) | |
{ | |
//Get the current controller class and set it as the | |
//body class attribute | |
$body_class = strtolower(get_class($this)); | |
// Index isn't a great id name, but since it's the index of | |
// the controller we set that | |
$body_id = ($method == "index") ? $body_class : $method; | |
$this->load->view('_shared/header.html', array('body_id' => $body_id, 'body_class' => $body_class)); | |
$this->$method(); | |
$this->load->view('_shared/footer.html'); | |
} | |
else | |
{ | |
show_404(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment