Well I think I did it with the following hacked function. I used a sculptor's technique ... removed bits of code until it worked.
PHP Code:
// ###################### Start gettemplate #######################
function getmytemplate($templatename,$escape=1,$gethtmlcomments=1) {
// gets a template from the db or from the local cache
global $DB_site,$templatesetid,$addtemplatename;
$gettemp=$DB_site->query_first("SELECT template FROM template WHERE title='".addslashes($templatename)."' ");
$template=$gettemp[template];
if ($escape==1) {
$template=addslashes($template);
$template=str_replace("\\'","'",$template);
}
if ($gethtmlcomments) {
return "<!-- BEGIN MYTEMPLATE: $templatename -->\n$template\n<!-- END TEMPLATE: $templatename -->";
}
return $template;
}
I'm not too clear how the template cache works, or what the $templatesetid and $addtemplatename variables are for - and maybe this will bugger up some other code - but so far so good, I'm happy. Thanks for your responses.