CodeIgniter Forums
Extending View File issue. - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21)
+--- Thread: Extending View File issue. (/showthread.php?tid=31940)



Extending View File issue. - El Forum - 07-07-2010

[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.


Extending View File issue. - El Forum - 07-07-2010

[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;
}



Extending View File issue. - El Forum - 07-07-2010

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

Leave view files where they belong Tongue


Extending View File issue. - El Forum - 07-07-2010

[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.