Welcome Guest, Not a member yet? Register   Sign In
Codeigniter OOP / controller question
#1

[eluser]Unknown[/eluser]
We use CI for the back end to our website template content management system.

Recently we have changed the front end code to a very OOP framework (our own as we had several dependencies where it needed to run both MVC and non-MVC for backward compatibility).

The front-end code is being extended so that it can run several different types of sites via OOP and extended (normalized) database schema.

I have started looking at how I can extend CI to allow overrides to Controllers / Models / Libraries / Views (Smarty) for different sites (we have around 20,000), hosts, by checking for the presence of override classes or templates in specified directories and extending from parent classes.

This is working okay by changing some logic in CI system folders in codeigniter/CodeIgniter.php and libraries/Loader.php [to check for presence of these files and include instead of app base ones].

I can override or replace any of said files for a specific site by moving base application classes in a parent directory and suffixing with _parent and then the current app controllers extend which allows overrides to extend with same class name as we are planning further extending.

Sorry for the long background now the question;

We have a controller / method for listing the contents of a page (page_builder.php / contents) what I want to do is check for the presence of specific page type class i.e.

product_page_builder.php (extends page_builder) if class file present then check for contents method if present call that function which will inherit from the parent (page_builder.php) to allow replacement, overloading per and post parent method call to change.

If child class or method not present return execution to parent (same class).

I cannot do this in CodeIgniter.php at core level like I have for site / host specific overrides as we need information like page type which is returned from database call requiring URI params so we are going into controller normal and then checking presence of overload controller and executing that way via factory style.

The issue with this like I have seen when I searched is that it doesn't load the CI models and libraries for use in the controller.

Is there any way to instantate a controller from within a controller with CI functionality.

I know perhaps it isn't best practice and we could achieve this with app rewrite to lib / model way but we are working to tight deadlines and am trying to achieve this with minimal app changes.

Any input / suggestions appreciated,

Mark




Theme © iAndrew 2016 - Forum software by © MyBB