<?php

function smarty_prefilter_theme($source, &$smarty) {

   if ($smarty->_tpl_vars['settings']['theme'] != '') {
     $theme = $smarty->_tpl_vars['settings']['theme'];
     $tmpl_file = './themes/'.$theme.'/tmpl/'.$smarty->_current_file;
     if (is_file($tmpl_file)) {
       $source = implode('', file($tmpl_file));
     }
   }
   return $source;
}
?>