Welcome Guest, Not a member yet? Register   Sign In
Load view outside the "views" folder
#8

[eluser]docmattman[/eluser]
For anyone trying to accomplish this same thing, I got it working by extending the loader class. It first checks to see if the file with the same name is located in the theme/views folder and if that doesn't exist, it loads it from the application/views folder install. Here is the code I used to do it.

Code:
<?php

class MY_Loader extends CI_Loader
{
public function __construct()
{
  parent::__construct();
}

/**
  * View Loader
  *
  * Loads "view" files from theme or view folder.
  *
  * @param string $view View name
  * @param array $vars An associative array of data
  *    to be extracted for use in the view
  * @param bool $return Whether to return the view output
  *    or leave it to the Output class
  * @return void
  */
public function themeable($view, $vars = array(), $return = FALSE)
{
        $themeFile = '/full/path/to/theme/views/'.$view.'.php';
        if(file_exists($themeFile)) return $this->_ci_load(array('_ci_path' => $themeFile, '_ci_view' => $view, '_ci_vars' => $this->_ci_object_to_array($vars), '_ci_return' => $return));    // Get from theme
        return $this->view($view, $vars, $return);        // Get from views
}
}


Messages In This Thread
Load view outside the "views" folder - by El Forum - 06-10-2013, 06:48 PM
Load view outside the "views" folder - by El Forum - 06-10-2013, 10:16 PM
Load view outside the "views" folder - by El Forum - 06-10-2013, 10:57 PM
Load view outside the "views" folder - by El Forum - 06-10-2013, 11:40 PM
Load view outside the "views" folder - by El Forum - 06-11-2013, 06:21 AM
Load view outside the "views" folder - by El Forum - 06-11-2013, 07:29 AM
Load view outside the "views" folder - by El Forum - 06-11-2013, 11:53 AM
Load view outside the "views" folder - by El Forum - 06-11-2013, 01:23 PM
Load view outside the "views" folder - by El Forum - 06-12-2013, 01:41 AM



Theme © iAndrew 2016 - Forum software by © MyBB