2008年12月15日星期一

[fw-mvc] Database driven, modular website structure

Hi all,

For a new site we are working on, I'm working on a structure that better
fits our requirements and workflow. Briefly:

URL's are being mapped to other URL's (alias) or a page (final). A page
represents a 'node' in the sitemap. A page is based on a layout, which
contains areas. Components are mapped to areas at page or layout level and
define the module, controller, actions that have to be executed. A page also
has a main component, which should always fire first.

Mapping components to areas allows for complex compositioning of pages.
Common elements can even be mapped to the layout to help enforce sitewide
look and feel. For instance the header, menu and footer might be mapped
through the layout, while the main content and a box with headlines and the
cloudtag might be mapped at page level. The idea is also that the SEM can
change page titels etcetera.

All data (urls, pages, layouts, areas, components) should be stored in a
database, so that non technical staff can change the site structure. I'm
running into two (slightly related) problems:

- How would you redirect (internally) the request if it is an alias? I was
planning on adding all the URL's as routes, but then you might have to
backtrack once you find an alias. Is that even possible? Another option
could be to create a route that completely resolves all aliasing until it
finds a final URL. I would also need these routes to assemble links and
other paths, since users might change URL's.

- How to control all the different actions that have to be done and put the
output in the correct place in the template? I have to directions of
thought: using (a modified version of) the ActionStack or creating a view
helper for use in the layout to call all the other actions as partials. The
first case might look a bit cleaner, but requires some major work between
the router and dispatch step (even create a custom router?). The second case
requires more attention to layout creation. Another disadvantage is that it
is difficult to add HTML head elements this way.

Typing away, I might have found a third and maybe THE solution. Create a
Plugin to fire at dispatchLoopShutdown that will fire all other components
and add the output to the layout. However, since this is outside view logic,
the Action view helper is not available? Or can I just do
$layout->getView()->action()? Will investigate...

Any feedback is welcome...

Kind regards,

Vincent de Lau
vincent@delau.nl

没有评论: