Part of the EllisLab Network
   
 
MVC within MVC (not view within view)
Posted: 06 January 2008 01:46 PM   [ Ignore ]  
Summer Student
Avatar
Total Posts:  27
Joined  09-30-2007

view within views appears to be a FAQ everywhere, but all responses that I saw until now was the “dumb views” type, like “load static header” your content here “load static footer”.

What if I have a MVC for a frontpage with configurable “slots” (left / right column, etc), with “10 ten news”, “5 most recent podcasts”, “static block”, etc.

Any block is a MVC in itself (its own controler, its own view, etcetera).

Any way to do this with CI with minimal fuss?

Profile
 
 
Posted: 06 January 2008 02:55 PM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  770
Joined  02-06-2007

You could call a helper from the main layout view that loads a specified library that returns the complete partial view. Maybe something like this example: http://codeigniter.com/forums/viewthread/59644/#293774

 Signature 

“I am the terror that flaps in the night”

Profile
 
 
Posted: 06 January 2008 03:45 PM   [ Ignore ]   [ # 2 ]  
Summer Student
Avatar
Total Posts:  27
Joined  09-30-2007

exacty, Hierarchical Model View Controller (HMVC) pattern does the trick.

The idea is creating controllers for my sub-blocks and instead of putting it in application/controllers/, put them in application/libraries/ ?

I’ll try.

Profile
 
 
Posted: 06 January 2008 06:10 PM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  770
Joined  02-06-2007

The “controllers” for the subblocks should actually be libraries - they just act like CI controllers.

 Signature 

“I am the terror that flaps in the night”

Profile
 
 
Posted: 11 January 2008 05:12 PM   [ Ignore ]   [ # 4 ]  
Lab Assistant
RankRank
Total Posts:  151
Joined  06-17-2006

If CI can acheive this, I’ll be on my way to building the perfect CMS wink.

 Signature 

CodeCrafter - Open Source Code Generation for CI

Profile