Welcome Guest, Not a member yet? Register   Sign In
CI Advanced User asking: Is strict MVC framework feasible in real world applications?
#1

[eluser]Ki[/eluser]
I have been using CI for a long time and wanted to seek some experience from all you CI experts. The question is whether deviations from strict MVC framework for ease of site management are common. Let me give you an example.
You have a site where certain sections are repetitive. Lets say you want to plug in latest posts or a list of related products in some pages of your site. In MVC, you would create a view for that little plugin, in controller you would load model to query db, maybe include some functions to pre-process data before it goes into the view.
... but when you have 3-4 different places where this little "plugin" needs to appear, it becomes a bit difficult to manage. Each time you need to remember to go back to controller and prep the date before you load that view as a section in another view.

The other option is to create a self-containing module that will query table, process the data and outputs it with all the right html tags, so whenever you need it on a page, you just do $this->load->view('latest_posts') and that comes with all bells and whistles required to successfully display that "plugin". But this will not advere to MVC framework because db calls, functions etc will be inside the view.

Any thoughts, suggestions based on all your experiences?
#2

[eluser]pickupman[/eluser]
It all depends on how strict you want to adhere to the MVC idea. It's the same type of debate with css and what is semantically correct. At first, it seems easy just to throw in a quick db call or call a library from a view or something like that. As your application grows, this approach become much harder to maintain. As a single developer, I don't have to worry about others finding code. If you are in a team, seems structure is a must.
#3

[eluser]WanWizard[/eluser]
imho this has nothing to do with MVC as such, but with modularity.

For cases like this you would like to create a module, that has it's own controller and view files, and maybe models or even libraries, and that would generate a partial when called.

That doesn't change the MVC pattern, but it's a more distributed way of processing. This is the implementation we have chosen for ExiteCMS, where module controllers produce screen elements or widgets, that are sloted into place by the theme engine which is called from the main controller.
#4

[eluser]luke holder[/eluser]
have a look into widgets / and modular separation.

wiredesignz widgets:
http://ellislab.com/forums/viewthread/109584


check out phils ideas here:
http://stackoverflow.com/questions/21271...35#2127335
#5

[eluser]n0xie[/eluser]
It sounds to me like you are looking for PAC or HMVC instead of MVC. This is rather difficult to do in CI and something that will hopefully be supported in the future.
#6

[eluser]Mark Croxton[/eluser]
Widgets are another way to 'pull' from a view rather than 'push' from a controller:
http://ellislab.com/forums/viewthread/109584

EDIT: redundant, didn't see post above with the same link.




Theme © iAndrew 2016 - Forum software by © MyBB