tags:

views:

22

answers:

1

Hello,

I'm currently writing an application that works with modules. The module part is all okay, but I am not entirely clear on what would be the best approach to display multiple modules on a same page. The way common MVC like systems could work is that an URL like "site.com/article/full/18543/how-to-lose-weight" (I'm not implying anything about you :)) -> would launch "article" -module and call its "full" -method with params "18543" and "how-to-lose-weight".

However, I'm writing an application where I need to have multiple modules on the same page. Currently, I let the user to create, delete and modify pages. He has an interface (a GUI) to decide how a page should look like. For example, he can name page "article" and make it to look like a two-column layout where he wants to have a shoutbox on the rightside in a sidebar and articles on the main body (the larger column). Now, how would I go for constructing the URL for something like that? I would like to keep my current page system, but I find it a bit hard to come up with a solution. You see, if the URL would load the "article" module, then the shoutbox wouldn't be loaded. So, I guess the URL is a reference to a DB entry containing the info about which modules to load? That's my current thought. So, after the user has created a page "article" and put two modules into the "article" -page (which is a two-column layout), then the URL "site.com/article/full/18543/how-to-lose-weight" would load the "article" -page, which tells the application the needed modules to load.

This leads me to two questions/problems. First, would the rest of the URL "/full/18543/how-to-lose-weight" go to the "article" -module or to the "shoutbox" -module? How do I determine that? The second problem is if this "shoutbox" -module has a link to register an account rather than posting as an anonymous, where will this link take the user to?

I'm basically trying to figure out a good way to build a relationship between different pages, modules and URLs.

Currently I have: Skins that handle the appearence and the possible positions where you can place modules. Pages that tell which modules are in which "page" and where they are positioned (in a skin).

And now I need to determine the way I work with URLs. Any help is welcome. :)

FYI: I'm using PHP and MySQL if that matters...

+1  A: 

I would suggest definitely going to a full-on MVC framework. If this (arguably simple) logic is troublesome for you, try to learn from the giants.

Even if you just dive into them to learn, and reply their concept; you're probably a bit better off.

CakePHP for example can use multiple controllers in 1 view, if required. It can also use something called 'elements' which allow to build up little views within a bigger view..

Think about it :) There is no direct need to completely connect urls and your controllers (thats what your modules are..). Also, you need to make sure your modules don't output any presentation markup (html), thats the view's job.

Evert