Skip to content

Instantly share code, notes, and snippets.

@devyfriend
Created April 21, 2013 07:49
Show Gist options
  • Save devyfriend/5428814 to your computer and use it in GitHub Desktop.
Save devyfriend/5428814 to your computer and use it in GitHub Desktop.
Codeigniter .... application/core/MY_Loader.php, ability do add / edit "views" folder location, good for themes, dynamic "views" location
<?php (defined('BASEPATH')) OR exit('No direct script access allowed');
/* load the MX_Loader class */
require APPPATH."third_party/MX/Loader.php";
class MY_Loader extends MX_Loader {
function __construct(){
parent::__construct();
}
/** Load a module view **/
public function view($view, $vars = array(), $return = FALSE) {
list($path, $_view) = Modules::find($view, $this->_module, 'views/');
if ($path != FALSE) {
$this->_ci_view_paths = array($path => TRUE) + $this->_ci_view_paths;
//
$view = $_view;
}
// hackery to apply application/themes/theme_name/views folder
$_theme = config_item('theme_current');
if($_theme) {
$_path = APPPATH.'themes/'.$_theme.'/'.$this->_module.'/views/';
$this->_ci_view_paths = array($_path => TRUE) + $this->_ci_view_paths;
}
return $this->_ci_load(array('_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment