Warning: Illegal string offset '_imagedir' in /home/cakephpf/public_html/lofiversion/index.php on line 545

Warning: Illegal string offset '_emodir' in /home/cakephpf/public_html/lofiversion/index.php on line 546
CakePHP UnOfficial Community Forum > Designing a Highly Modular Site in CakePHP
Help - Search - Member List - Calendar
Full Version: Designing a Highly Modular Site in CakePHP
CakePHP UnOfficial Community Forum > Layouts and Design

Hi Everyone,

I'm ran across this board looking for an answer to an MVC design question. I've been searching for an answer for a while and haven't really hit upon anything that works cleanly. I'm hoping to extract some wisdom from the more experienced cakephp crowd.

Basically the challenge is this: to create a framework with many modules built in an MVC framework, which can be implemented to quickly construct any number of sites with any number of different page layouts, implementing the same core modules.

I have all of my standard units of data - posts, comments, polls, events, user accounts, etc - and each will have a few standard representations. For instance, I may have a post creator, an all posts landing page, a related posts list for the sidebar, etc. Each of these representations will have a different view that needs to be plugged into pages like a widget.

So I have many of these "widgets" that will all need to be placed into my pages, but I want to use my pre-packaged controllers and views for the module, since any place I'm using comments will have the same design, whether the comments are on a post, a user profile, or an event listing.

I know I can accomplish this with loads of requestAction calls, but that's going to be prohibitively slow on pages with more than 2-3 modules. But the alternatives I've seen to requestAction don't really seem to address this problem.

Any thoughts?
Okay, I have a proposed solution to this challenge, which I thought I'd run by everyone.

Basically, the solution is this:

Specify two standards, a widget and a page.

A widget =
model -> component -> element

A page =
controller -> view

So assume you need modules A, B, and C to appear on page index. In the page controller, create a function called index and load in the components that relate to modules A, B, and C. Then pass to the index view, where the elements for modules A, B, and C are included.

I still need to review the documentation and build out how all of this data would be passed - i have not worked with components or elements in the past. Does this seem like a reasonable way to tackle this challenge? Does anyone know a better solution?
To create a real modular website with CakePHP you need to rewrite the routing, controller, model and view classes of the core. When done correctly you can have the following directory structure:


This way you can fully separate the modules from the rest of the application/website.

I know there's already one project which is trying to do this, which is Mambo CMS. It requires some searching at their website, but you can access the current files which made a start to modules.

Thanks for the reply, Terminal13. After researching this for a bit, I found that Zend offers a similar implementation to what you're suggesting (see here: Using a Conventional Modular Directory Structure).

But, that said, there are a lot of benefits to a full stack framework like Cake so I'm really more inclined to try and make it work smile.gif So...what about the concept of plugins in Cake? The directory structure looks like this:


           /controllers                <- plugin controllers go here
           /models                     <- plugin models go here
           /views                      <- plugin views go here
           /pizza_app_controller.php   <- plugin's AppController, named after the plugin
           /pizza_app_model.php        <- plugin's AppModel, named after the plugin

Has anyone used plugins before to accomplish this kind of a modular design? Pros and cons of taking this approach? Also, how are the Mambo CMS modifications different from standard plugins?
Okay, I take that back. It doesn't appear that plug-ins are really as versatile as I believed. According to the documentation, they can only be accessed by URL, and are loaded in the same fashion as standard controllers.

This is more what I had in mind...but as the author observes, it doesn't exist.

Am I wrong? Could plugins be the saving grace?
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2015 Invision Power Services, Inc.
Lo-Fi 1.1 iDS Beta, Originally written by Matt,
re-written by Shaun Harrison, Layer 04.com, for pre IPB2.0 versions.