PHP automatically gets the code for the template in the directory

  • 2020-03-31 20:59:40
  • OfStack

Default.gif (shown here as a template thumbnail) must be in the directory to be a valid template
 
function get_template () 
{ 
$template = array (); 
$dir = CMS_ROOT.'/tpl/'; 
$n = 0; 
if (is_dir($dir)) { 
if ($dh = opendir($dir)) { 
while (($file = readdir($dh)) !== false) { 
if ($file =='.' or $file == '..' or $file == '.svn') 
{ 
continue; 
} 
if (is_dir ($dir.$file)) 
{ 
if (file_exists ($dir.$file.'/default.gif')) 
{ 
$template[$n]['dir'] = $file; 
$template[$n]['pic'] ='/tpl/'.$file.'/default.gif'; 
} 
} 
$n++; 
} 
closedir($dh); 
} 
} 
return $template; 
} 

Related articles: