About six months ago, I started work on a small PHP project. It involved a relatively simple concept with an identical method of loading and displaying content but each set would have a custom look and feel*. It seemed liked a relatively straight-forward small-scale Content Management System with a transform layer in front.
At the beginning, I evaluated using Drupal to see how it would work for our needs. Although it did aspects of what we were looking for, it didn't seem to support the dynamic theming required. Regardless, there were a few aspects which Drupal did beautifully, so I pulled a few of those functions – properly attributed of course – and adjusted them for our purposes. A small but useful success.
Then I began on the templating side of things. There was already an effort to convert dotProject over to using Smarty Templates for theming and so I investigated that as an option. The tag/insert format felt natural after working with JSP tags and it was already in use for dotProject, so those were huge plusses. Unfortunately, it seemed like a much heavier solution than we required. With the first milestone looming, I was able to capture requirements for the next few milestones and decided against Smarty and implemented a really simple template system.
Bringing the first few sites online was incredibly simple. Each had very similar aspects and my simple templating system – let's call it “Dummy” – worked beautifully. It was easy, fast, lightweight and mostly web designer friendly. Thinking about it a bit and getting new requirements, I managed to extend it in a number of unexpected and useful ways in almost no time at all. Unfortunately, this little CMS has begun to take off and caught the eye of a handful of big names. Another few rounds of requirements, additional considerations, additional feedback, and a bit of logic and I found that I've implemented a much less flexible and less extensible version of Smarty. Don't get me wrong. It works, it's relatively efficient, and I can extend it with almost no effort but unfortunately, it's also a “Keith Original” and is not a long-term solution. So I dug back into Smarty…
After adding the libraries to the project, I tweaked my template generation and variable assignments and prepared for a world of hurt. I began with the smallest template and prepared for a screen full of errors and an afternoon of debugging. Control-R and what did I see…
My page loaded. My page didn't just load, but approximately half of the variables were populated with the correct values. Although the engine side of the system was just a shadow of Smarty, the template formats were so similar that huge portions of the site worked. Apparently, I had learned enough from Smarty so that even when I was doing it wrong, I was doing some of it right.
No, I don't recommend building your own anything right off the bat. Dig around and look at what is already available and out there. Even if something is heavy for your initial requirements, learn a bit about it, how it works, and where its weaknesses are. Who knows, you may end up in a scenario where some simple design thoughts early on could save you hours or even days of work.
* My apologies for the vagueness. Some of the sites are released and for public use and some are not. Once more of the sites are available, they will be announced here.