Welcome Guest, Not a member yet? Register   Sign In
Front Controller or smth?
#1

[eluser]Unknown[/eluser]
Hello Everyone Smile
(my first post here ;] ),

First - I'm kinda new to CI. Got my hands on it before (version 1.7 i think).
Gone through user guide, tested basic functionalities. Now I started to write an insurance policies management system + CRM (next on the road).

I'm stuck with one thing - Is there something like front Controller for CI?
What I mean by that is :

- I need a modular application where I can get one module from one CI installation, copy it to another different or even clean installation and get it working - Plug&Play;. ( I mean only code - not the DB - its a different problem).

I've tried HMCV, but what it does its like many applications in one. Each module has its own models, controllers and VIEWS. Moreover separate routes.

What I'm looking for is something like this:
- Front Site with some default template
- Modules as "boxes" in header, center, footer (maybe more..)
- When requested normally by passing URL in GET request site is loaded with default boxes
- if additional params in url - different boxes
Here i hear - its simple - just load modules outputs in theme variables and load it. But problem is when it comes to AJAX - then I don't want to have whole theme - just module output, because I'll be changing 'boxes' with ajax requests.

tried something like this (example):
Code:
function _remap($method='',$args=array())
        {
            if(!empty($method) && $method!='index' && method_exists(&$this,$method)){
                return call_user_func_array(array(&$this,$method),$args);
            }
            $content = Modules::run('insurances/policies/'.$method,$args);

            return $this->load->view('main',array('content'=>$content));
        }
Seems to work because:
- If called from site (index.php/main/*) loads module's method as variable in main view
- If called from module (index.php/insurances/policies/*) loads only module's method's content

But 2 problems then:
- changing routes gets messy
- if module displays some urls using url helper it also gives wrong urls.


I'm feeling like like I'm doing something contrary to convention or reinventing the wheel. True is I need something like this portable modules and NO, I can't use some overblown CMS (where there is something like plugins or modules).

Any Ideas? please? Smile




Theme © iAndrew 2016 - Forum software by © MyBB