Simple Content Management (with Templates & Permissions)

I’ve been working on a sort-of content management system at work and I wanted to get some opinions on the structure of it. Here’s the basic summary:

I have a database table that keeps the content for me (title, content, date stamp, etc) – each item has a type. My goal was to have a system that would be flexible and allow me to store both hierarchal and date sorted information easily and all in one place. I set out with the intent to make it something I could potentially use for simple blogs, forums and even static content like FAQs.

Basically, everything is a child of something – there’s a starting point (the top parent) and all of the children from there down. Since it’s on Oracle, CONNECT BY is my best friend. I can point it at a parent and get back a recursive array of the values. So, if our top level was “blog” then its children might each be a “blogentry” with each of those having a collection of “blogcomment” content blocks.

You can see how the same sort of thing could apply itself to a forum layout (remarkably similar, actually). Parent/child all the way down, allowing for any number of nested levels of categories and topics.

Now comes the fun part – the PHP code.

I’m not quite done working all of the kinks out of it yet, but it’s close. Here’s the though process behind it, though. A fetch() function is called on the top-most parent to get it and its children’s data. This is passed to a display() call to be handled. Inside of the display() call is a bit of logic that starts looking at the types of the data. The TYPE column in our table is really the key to how the whole system works. The display() logic looks at the type of the first item of data passed in and loads in a Helper from a predefined directory (include_once, of course). These are named according to the type they help with – so HelperBlog helps with type “blog”, HelperBlogentry helps with “blogentry”, etc. These are loaded, a new object is made and the display() method is called on it.

The children are passed in to this method where, if the child class (HelperBlog or whatever) chooses, they can be iterated over. The fun thing is that since the class extends our main class (in my case DynContent), we can just call the parent::display() method with the child data and it will recurse down through each of the layers.

There’s more to it than just this (templating, permissions, etc) that I’m still working on, but it seems like it has potential. I’m curious as to if anyone else out there has approached this kind of idea in a similar way. I’d love to hear feedback/comments/whatever about the idea from anyone out there.

I don’t have the code posted anywhere yet, but if you have an interest let me know in the comments.



  1. Am thinking in a system like that for a while. Its like creating a relational database

    You should take a look at drupal and its internal architecture. It has a table of generic nodes that are expanded on design-time (by the modules) and run-tme (by the cck module) to custom the content. It also features a permissions mechanism that’s very simple and extensible. The only but is that both the modules and permissions are not recursive.


  2. I’ve built a system similar to this the other week, it worked extremely well for what we needed – news, content and services with children services pages. I guess if all types of page follow the same style with the same kind of data this will work, In my case it was something like, title, heading, content and meta data, fairly simple really.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s