Forum Moderators: coopster

Message Too Old, No Replies

How to introduce customisable snippets (modules) in MVC architecture

         

luismartin

11:06 am on Oct 30, 2011 (gmt 0)

10+ Year Member



I feel very comfortable using the MVC architecture when building a website. And now what my clients want is the possibility to customise their content from the backend in a way that they can populate the main menu with their own options, and within each one, they can assign a specific number of snippets (I will call them modules), from a predetermined number of types of modules, in a specific position of the page. For instance, a module which displays slides, a module which displays contents in a grid, etc.

It would be something similar to what Joomla does, but simpler. I don't want to use either Joomla or any other CMS in this case. I will use an MVC framework with no application on it.

What would you consider a good approach to implement this relationship among menu options, modules and positions?

My idea is to create a DB table called "modules", whose records are any module the administrator creates, with its type, some field to store the specific settings for this type of module (I'm not sure how to do it yet).

Besides this, the table "mainmenu", which stores all the options within it, and every option would have a field in which store the modules id's to display, and their position in the page, so that when rendering the view, ask for any position which module to display.

What do you think of this way to do it? Or do you think there is a better way? Any suggestion would be greatly appreciated.

Wittner

12:09 pm on Nov 8, 2011 (gmt 0)

10+ Year Member



Can't see anything wrong with your approach. I use CodeIgniter for my MVC stuff (it's a light architecture, very flexible in how you use it) and perhaps if I was using this I might look at my own view controller which appends views to the menu view according to which options were chosen by the user. This way you would cut down on DB calls. Just a thought!

cheers,

Mike