Sorted out my problem re conditionals not getting parsed.
gettemplate actually contains two return statements - the first executed only if you have enabled template debugging. I had this option enabled, so the call to advanced_templates was not being made.
you need to make the following change to gettemplate
PHP Code:
if ($gethtmlcomments and $addtemplatename) {
return advanced_templates(
"<!-- BEGIN TEMPLATE: $templatename -->\n$template\n<!-- END TEMPLATE: $templatename -->"
); }
return advanced_templates($template);
Great job, thanks