I’m : a web and mobile developer based in the Manning Valley, Australia.

Custom CMS

Whilst I still don't have a name for my CMS system it is progressing along nicely. Last night I managed to add in support for caching and completed the storing of backlinks (which are used to power the See Also sections). Pages are cached until we re-run the script to index the site resulting in the whole page, including side-bar entries, being served directly from cache extremely quickly. This method might not be great for dynamic sites but then it's not meant to support that.

At the moment a re-index means reading through all the content in the site, deleting from the Lucene database and then re-adding. This will be modified to capture the last-modified timestamp from the filesystem and compare that to what was stored in the Lucene database for that entry. It might in a bit of a performance hit having to retrieve the document to do the comparison but as soon as the content base grows it will be better than re-indexing everything from scratch.

One thing that had me scratching my head was blank pages showing up when doing Page caching in Zend_Cache. Normally this should not be an issue but I was performing a few redirects, changing default controllers etc. So Zend was noticing that I had gone to a particular URL, found a cache hit and tried to service that. But because there was more going on in the background (me overriding defaults) Zend_Cache actually had no real content to serve even though it thought it did.

The solution was to enable Zend_Cache but set it up to, by default, not cache anything. Then I added support for caching /universe/. Now that is not a controller itself which I think was causing my other issues earlier. As for example when you tried to go to http://site/ the first time it would send you off to http://site/universe/ correctly but going to http://site/ the second time would return a blank page. The default controllers index action does a redirect to /universe/ which is then picked up as a route and my showAction called.

As for the backlinks those are worked out when indexing a document. I find all occurences of a href="" class="wikilink" and pick out the URL from there. We already know what the 'url' of the current page would be and then we construct something like:

    $backlinks = array();
    foreach($link) {
        $backlinks[$link] = array(
            'pageTitle' => $currentPageTitle,
            'pageUrl'   => $currentPageUrl

This way we end up with a nice array and when the user lands on a page we can simply iterate over the entries contained in $backlinks[ $url ]. This is then stored in the cache as a serialised array which we can grab out at a later date.

The following things still need to be sorted out:

Right now I am not too sure on how to setup RSS feeds without hard-coding too much. In theory it's the same details as the front page of the site, just rendered using a different template and all should be fine. But the way I've written it the showAction automatically defaults to the 'simple' template if more than one entry is being returned by the model.

I guess what should be done is the ability to set a master template for a collection of items. But again that might be hard-coded until I can figure out how to get a plugin system working. Nothing too serious for now since it's not like I need to subscribe to my own posts :-)