::UPDATE - 04.09.2009::
I finally was able to
create an example of the below described site. If you have any questions/comments please
let me know.
When creating a website, especially in the corporate/enterprise world, it assumed that you have to use some sort of
content management system. The range, and subsequent debate, could be everything from free (
Joomla,
Wordpress,
Drupal) to the very expensive (
Vignette). While I am in a firm believer in the use of a CMS it seems lately I have been asked to develop sites whose content doesn't change that often, but the responsibility still needs to fall into the hands of a content editor not a developer. In addition,
the designer that I work with wanted the freedom of creating as many templates as he wanted and tweak the design without having to consult me, the developer, nor have to work with a content editor to update any of the content pages.
I went back and forth how to best solve this solution. While Joomla and Wordpress would have certainly handled all of these requirements there is the overhead that comes with any CMS and with the requirements that I had to work with I kept asking myself if using a CMS was lighting a grill with an atom bomb.
The end result was a hybrid between using static "html" and a mini-CMS....all using the
Zend Framework. I came up with a way that separated the content, layouts, and the developer maintained backedend of the site.
Basic requirements:
- SEF's
- Breadcrumb subheadings
- Flexible layouts - some pages might need a "one column content well", "one column content well with a side bar", etc
- Content pages should be kept in one location
- Templates should be independent of backend code and content
Directory Structure:
- content
- css
- images
- index.php
- js
- layouts
- lib
- modules
- settings
How It Works
- Creating/Editing Content
- Create the static phtml file in the content directory
- Edit the content.xml file in the content directory and add the following attributes and/or nodes: url - 1) what the request url will be. 2) file - the name of the phtml file (minus the extension). 3) pageTitle - self explainatory 4) layout - what template do you want to use for the page
- Page Rendering
- Zend Layout
- Zend MVC
- Custom regex route
- Custom Site Page Render Plugin
Plugin and Go
The majority of the site dynamics happens in the custom plugin - routeShutdown method.
- Based upon the $_SERVER['REQUEST_URI'] the appropriate "page" node is located: "//pages/page[@url='{$_SERVER['REQUEST_URI']}']".
- The page title is set
- The name of the view (phtml) file is set
- The breadcrumbs array is populated. *
- All the attributes are then set as an array of params and set in the request.
- The IndexController/indexAction grabs the params, sets them to view properties to be displayed in the layout
*::NOTE::
Since there is technically not a hierarchy of files on the web server... the way that the url is decided upon is by the content editors. Because of this there is a business rule in place that the "toplevel" navigation is the first set of characters in the url and child navigation thus follows. In the method the breadcrumbs are created by parsing this pattern.
Conclusion
While there is definite room for improvement to how the site management is done we have seen great efficiency not only how the site is maintained and content is created, but also the amount of code that is used to generate the site.
- 1 module, 1 controller, 1 action, 1 custom plugin
- developers, content editors, and designers are able to work on their respective portions of the site without having to rework or update any other aspect of the site in 99% of use cases.
I finally was able to
create an example of the below described site. If you have any questions/comments please
let me know.