extendible controllers and models |
[eluser]Lotti[/eluser]
Hi everybody! We (developers of a webagency) are trying to use CI to develop our systems (CMS, ecommerce) and we wanted to add a nice feature that will save us a lot of time. Let me clearly explain what we need: - we want to keep the "base" code (i mean "the original code of our CMS") separated from the various customization for customers. - the customization file could not exists. - every hack must be inside application folder. I'm quite expert with codeigniter and i alreday hacked the router class, but i don't like it so much. I need your opinion. Actually, my hacks works like this: Directory structure Quote:application/controllers/CMS/ --> here we want to keep the original CMS controllersa similar pattern could be used for models too (i haven't hacked models loading yet) then, my controllers will be: Quote:application/controllers/CMS/cms_page.php --> father class then inside the routing config file i have to write the "default behaviour" for each controller, e.g.: Code: $route['page'] = "cms/cms_page"; Then i hacked the Router CI class like this, overloading _validate_request with a check for a customization class between the search in root folder and in sub-folder. The algorithms simply checks the existence of "page_cms.php" in the root and call it instead of call CMS/cms_page.php Code: .... What i don't like of my solution is that i have to write a the "default behaviour" for each controller inside application/config/routers.php. Maybe an easier solution to this problem will be just to use an unique identificator (like CI does with MY_) instead of CMS and Ecommerce. Do you have any better idea or already solved something like this? Thank you.
[eluser]Lotti[/eluser]
an answer like: "it already exists a php framework that does what you need" would be appreciated too!
[eluser]porquero[/eluser]
For extend CI you have various alternatives: - Creating libraries - "Extending" Helpers - Using Hooks for extend core Also I recomend use HMVC plugin. You'll can manage applications better. There are more ways to customize CI. You can find in user guide. I hope help you. |
Welcome Guest, Not a member yet? Register Sign In |