Welcome Guest, Not a member yet? Register   Sign In
Extending View File issue.
#1

[eluser]JasonS[/eluser]
Hi,

I am having a problem with loading view files.

I don't really understand how the system is getting the path to view files. I have an external place where some view files are being stored.

I wrote this little hack to extend the loader class.

Code:
public function view_page($file, $data, $load, $path) {
    $sys_path = $this->_ci_view_path;
    $this->_ci_view_path = $path;
    $this->view($file, $data, $load);
    $this->_ci_view_path = $sys_path;
}

Does anyone know how to do this properly?

For some reason the ob_start() on line 665 of Loader.php seems to be the breaking point. The view file path can be printed out before ob_start() yet not after. Other view files load fine.
#2

[eluser]JasonS[/eluser]
I solved this, I was forgetting to return the function.

This is the updated function.

Is there a better way to do this?

Code:
public function view_page($file, $data, $load, $path) {
    $sys_path = $this->_ci_view_path;
    $this->_ci_view_path = $path;
        
    $result = $this->view($file, $data, $load);
        
    $this->_ci_view_path = $sys_path;
        
    return $result;
}
#3

[eluser]danmontgomery[/eluser]
[quote author="JasonS" date="1278531385"]Is there a better way to do this?[/quote]

Leave view files where they belong Tongue
#4

[eluser]JasonS[/eluser]
[quote author="noctrum" date="1278531614"][quote author="JasonS" date="1278531385"]Is there a better way to do this?[/quote]

Leave view files where they belong Tongue[/quote]

This unfortunately is not an option. The application requires a degree of separation between core files / modules and themes. Placing these files in different subdirectories of the views folder unfortunately is not enough.




Theme © iAndrew 2016 - Forum software by © MyBB