0
votes

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; }
}
?>
1
You might be in need of hmvc for CI. Haven't used CI in a while but allows MVC design pattern, calling controllers/views and extras from different controllers, all pluses imogwillie

1 Answers

0
votes

I've found my own answer. It was a good searching. I have search every file in the core folder of codeIgniter and I have made a new constant that's APPPATH_OWN and by every function of view, controller models and so on I have made a function to first check OWN pathfile than the normal one.

In the folder core I have finally edited the following files.

Router.php
Common.php
Config.php
CodeIgniter.php
Loader.php

In the folder databases I have changed the DB.php folder.

I had hoped that there was an easier solution.