Adding arbitrary PHP to a CMS Made Simple website

CMS made simple (CMSms) is great as it does what it says on the tin e.g. it's a CMS and it's easy to use and configure. Most importantly for me, it's easy to skin and modify.

It uses Smarty as a template engine and I have to admit that I was dubious when I saw this as I've never ever seen the point of making up a set of arbitrary commands that one has to embed within markup when one could just include PHP in the first place.

Anyway, working with CMSms on a few (not yet live) personal projects I can see how at least one aspect of Smarty is pretty cool and that is the concept of tags. In CMSms it is possible to drop in one of the many supplied tags that abstract the code away from the, lets assume, designer putting the website together. For example:

[html]
{clever_menu_system}
[/html]

Being an impatient developer wanting to insert arbitrary code direct into the template I had to figure out how to create my own tags, so here's how:

Edit config.php so that

[php]$config['use_smarty_php_tags'] = true;[/php]

Go to the admin screens and select Extensions -> User Definied Tags

Create new, giving the tag a name (underscores instead of spaces) then create a tag thus:
[php]
?>

<?php
for ($x=0; $x<10;$x++)
{
print "This is easy
“;
}
?>

<?php [/php]
Note that I have to close the PHP tags at the beginning of the tag and also that after the ending opening PHP tag one needs some whitespace.

Another, aguably more messy approach would be to add PHP directly into the template, this can be acheived through the use of {php} and {/php} tags to replace the tags.

Related:
CMS Made Simple
CMSms dev site