I have a problem with codeIgniter and I can't find an answer. What i'm trying to do is to build a CMS with one manage system that manage multiple sites. I have standard classes and functions but sometimes one site works others than an other site so I need to change a controller specifically for that site.
My problem now is that I don't know how I can change the autoload controller/models and view where it must look first in it's own folder if it's exists. If exist load file from own folder else use the global files.
In other ways I need this.
controller news (http://mywebsite.com/news/ In directory. Own file folder is /home/user/domains/website/public_html/codeIgniter/controllers Global folder is /home/libs/codeIgniter/controllers
The global folder is set at the settings of the index.php for the website.
First it needs to check the first file for the file. If not exists use global file. I hope you can help me.
I've added a code that does almost the same but then with the view controller and then it's an other function. I also want to make a standard function of this one so i don't need to use other functions than the standard one.
Thanks.
<?php
/* !DESCRIPTION: This method behaves the same as the default $this->load->view() except it allows you to
include files outside your root application view folder. It will change the path, include the file,
then change the path back to the original. Nice to have when using shared templates over multiple sites.
*/
//!VAR -> $path :: The absolute path to the view folder (IE: /var/shared/codeigniter/views/)
//!VAR -> $view :: The view file name (IE: shared-header)
//!VAR -> $data :: The variables and values you wish to pass to the view, if any (Defaults to empty array())
//!VAR -> $return :: Set to TRUE if you want to return the value rather than add to the view (Defaults to FALSE)
function external_view($path, $view, $data=array(), $return=FALSE)
{
$__ci =& get_instance();
$op = $__ci->load->_ci_view_path;
$__ci->load->_ci_view_path = $path;
$v = $__ci->load->view($view, $data, $return);
$__ci->load->_ci_view_path = $op;
if ($return === TRUE) { return $v; }
}
?>