When is a tree not a tree

The words “Bespoke CMS” should always put you on your guard. Is any company’s CMS requirement so unique that no other available tool (open-source or commercial) will do? You just have to create from the ground up? No, really?

I maintain (for my sins) a legacy bespoke CMS. A tree-based CMS where the hierarchy of the content is actually represented as a content tree, with parent nodes, child nodes and all that jazz. And it’s just wrong. The hierarchy of a website content is a convenience for the user: what does it mean for one item to be the parent of another? If you have a URL, you can navigate up the hierarchy to arrive at the URL for the parent node, but all you need is to parse the URL.

Drupal, of course, stores nodes as: nodes, potentially with an associated alias (a friendly URL). So, despite the time that we (I) spent at Uni writing code to traverse tree structures, what we have here is not a tree, at least not internally.

The lessons here are:

  • Don’t over-engineer. A computer science assignment solution may be more than you need
  • Your requirement is really not that special, if you’re doing it a different way to everyone else, you’re probably wrong