Part of the EllisLab Network
   
 
MVC within MVC (not view within view)
Posted: 06 January 2008 12: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 01:55 PM   [ Ignore ]   [ # 1 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  840
Joined  02-05-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 02: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 05:10 PM   [ Ignore ]   [ # 3 ]  
Research Assistant
Avatar
RankRankRank
Total Posts:  840
Joined  02-05-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 04:12 PM   [ Ignore ]   [ # 4 ]  
Research Assistant
RankRankRank
Total Posts:  558
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
 
 
   
 
 
Post Marker Legend
New Topic New posts Hot Topic Hot Topic with new posts New Poll New Poll Moved Topic Moved Topic Sticky Topic Sticky topic
Old Topic No new posts Hot Old Topic Hot Topic with no new posts Old Poll Old Poll Closed Topic Closed Topic Announcement Announcements
Theme
Change Theme
Visitor Statistics
The most visitors ever was 819, on March 11, 2010 11:15 AM
Total Registered Members: 120536 Total Logged-in Users: 40
Total Topics: 126598 Total Anonymous Users: 3
Total Replies: 665552 Total Guests: 399
Total Posts: 792150    
Members ( View Memberlist )
Newest Members:  sweeper240andrew nsuntroprachel123Rach123Glenn StavaImfaelSMS!persanulandrewknight