PDA

View Full Version : PHP: template handling: "if template exists"


robertusss
Tue 25th May '04, 12:48pm
Hi,

is there an easy way to check if a template with a certain name does exist; like:
if (template_exists('abc'))
{
echo "abc exists";
} else {
echo "nope";
}

I mean I could code some SQL-thing that checks the database everytime SELECT * FROM template WHERE title='abc'
but I would like to use the internal templatefunctinos as much as possible (because of template caching etc)

THX

robertusss
Tue 25th May '04, 12:54pm
erm, sorry, could someone move this thread to "PHP Coding" please.

Thanks

robertusss
Tue 25th May '04, 1:01pm
and again sorry, I made this function in vb2, I just need to know how much the templatesystem changed since then:

function FFF_existstemplate($templatename) {
// checks if there is an template of that name, if yes it is also put in the cache
global $templatecache,$DB_site,$templatesetid,$addtemplat ename;
if (isset($templatecache[$templatename])) {
return true;
} else {
$gettemp=$DB_site->query_first("SELECT template FROM template WHERE title='".addslashes($templatename)."' AND (templatesetid=-1 OR templatesetid='$templatesetid') ORDER BY templatesetid DESC LIMIT 1");
$template=$gettemp[template];
if ( isset($template) ) {
return true;
} else {
$templatecache[$templatename]=$template;
return false;
} } }
problem is, i don't understand that templateassoc and the new id system...