CodeIgniter Forums

Full Version: Is that possible to load a view which is not in views folder
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[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

El Forum

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

El Forum

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

El Forum

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

El Forum

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

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