Version checking for Serendipity templates

I’ve been experimenting with the new theme configurator for Serendipity. I’m hoping most users will upgrade to version 1.1 of Serendipity once it reaches a stable state although being a realist I know this isn’t going to happen overnight.

This means we may end up with a selection of new templates that are compatible with the theme configurator but cause issues for users with older versions of Serendipity.

The solution is to make Serendipity perform a simple check to see if the user has a compatible version of Serendipity installed, and then provide alternative code if they don’t.Sounds simple, and in fact it is. Within our smarty code we need to add an {if} statement;

{if $head_version < 1.1}do something{else}run configurable options{/if}

A simple example of this in use could be a navbar link. Prior to the theme configurator its been necessary for the user to edit their smarty template files (usually index.tpl) to make their links.

Users who don't have 1.1 will still need to edit their files, but at least they won't need to change the code that allows the configurator to work when they eventually upgrade.

{if $head_version < 1.1}
<li><a href="link.url">link.text</a></li>
{else}
<li><a href="{$template_option.navlink1url}">
{$template_option.navlink1text}</a></li>
{/if}

As you can see from this simple example template designers can be sure their theme will remain backwards compatible, and users who choose not to upgrade will still be able to edit their links just as they've always done so all the existing documentation for templates remains unchanged.

Comments are closed.