CodeIgniter Forums
Is that possible to load a view which is not in views folder - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Is that possible to load a view which is not in views folder (/showthread.php?tid=12087)



Is that possible to load a view which is not in views folder - El Forum - 10-05-2008

[eluser]datactrl[/eluser]
HI, all

I have some very general view files can be used by different application. I would like to save it in a special folder for different applications to load. With $this->load->view(), it seems not possible. However, is there a work arround to do it? Thank you!


Jack


Is that possible to load a view which is not in views folder - El Forum - 10-05-2008

[eluser]Colin Williams[/eluser]
I would have your views folder, or a sub-folder symlink to the other folder.


Is that possible to load a view which is not in views folder - El Forum - 10-05-2008

[eluser]marcoss[/eluser]
Or use php include.


Is that possible to load a view which is not in views folder - El Forum - 10-05-2008

[eluser]xwero[/eluser]
You can make a view directory in the system directory and do something like
Code:
$this->load->_view_path = BASEPATH.'views/';
$this->load->view('general_view');
$this->load->_view_path = APPPATH.'views/'; // reset class variable for other views
You could extend the loader class with a method to cut down the code in your controller.


Is that possible to load a view which is not in views folder - El Forum - 10-06-2008

[eluser]Phil Sturgeon[/eluser]
The paths can be relative too.

Code:
$this->load->_view_path = '../wherever/views/';