Welcome Guest, Not a member yet? Register   Sign In
3 Sites Almost Identical Codebase
#1

[eluser]Unknown[/eluser]
Hi,

I'm looking at CodeIgniter for a possible solution to my problem, however have no CI experience - Most of my work is in Drupal, but in this case it's not right for the job.

I have 3 applications, which are currently separate codebases. The differences between them are small, although they do go deeper than view level.

Is there a simple way in which I could use CodeIgniter to develop one base application, where more specific Views etc are loaded if they exist, based on a configuration setting that says what version is running?

Many Thanks,
Peter
#2

[eluser]WanWizard[/eluser]
Shouldn't be to difficult.

If it's limited to views, you could create a folder for every version in the views directory, and use
Code:
$this->load->view( $version.'/my_view_file' );

If your application requires view folders, you could add a method to the loader library (or in your MY_Controller):
Code:
function function versioned_view($folder, $view, $vars = array(), $return = FALSE)
{
    // store the current view path
    $path = $this->load->_ci__ci_view_path;

    // alter the view path so it points to our version folder
    $this->load->_ci__ci_view_path .= $folder . '/';

    // load the view
    $this->load->view($view, $vars, $return);

    // restore the view path
    $this->load->_ci__ci_view_path = $path;
}

If it involves different underlying code, it gets more complex.
#3

[eluser]Unknown[/eluser]
Thanks for that! That looks straight forward enough, although I do have underlying controller/model differences as well.

Just trying to work out a solution that uses some form of inheritance rather than a whole pile of 'if's or switch statements.

Peter




Theme © iAndrew 2016 - Forum software by © MyBB