Changeset 843 in ExiteCMS for trunk/includes/theme_functions.php


Ignore:
Timestamp:
09/27/07 19:34:07 (5 years ago)
Author:
hverton
Message:

Moved all CMS templates from the theme to the include directory. They are theme independent
Added a Smarty resource to load templates from strings
Some XHTML fixes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/includes/theme_functions.php

    r841 r843  
    2727$template->compile_check = true; 
    2828 
     29// set the compile ID for this website 
     30$template->compile_id = $_SERVER['SERVER_NAME']; 
     31 
    2932// caching required? 
    3033$template->caching = 0; 
     
    4447// and finaly, use the default Smarty plugins 
    4548$plugins_dir[] = 'smarty-plugins'; 
     49 
    4650$template->plugins_dir = $plugins_dir; 
     51 
     52// templates, where to find them? 
     53$template_dir = array(); 
     54// first check if there's one defined in the current theme 
     55if (is_dir(PATH_THEME."templates/source")) $template_dir[] = PATH_THEME."templates/source"; 
     56// next, check the CMS template directory 
     57$template_dir[] = PATH_INCLUDES.'templates'; 
     58 
     59$template->template_dir = $template_dir; 
    4760 
    4861// PHP in Templates? Don't think so! 
     
    158171            } 
    159172 
    160             // if this is a module template... 
     173            //if this is a module template... 
    161174            $tpl_parts = explode(".", $panel['template']); 
    162175            if ($tpl_parts[0] == "modules") { 
    163                 // check if there is a customized version for the current theme 
    164                 if (!file_exists($template->template_dir."/".$panel['template'])) { 
    165                     // if not, add the module template to smarty's source list, so the default template can be found 
    166                     $template->template_dir = array(PATH_MODULES.$tpl_parts[1].'/templates', $template->template_dir); 
    167                 } 
    168             } 
     176                // store the current template directories, we need to restore them later 
     177                $td = $template->template_dir; 
     178                $template->template_dir = array_merge(array(PATH_MODULES.$tpl_parts[1].'/templates'), $template->template_dir); 
     179            } else { 
     180                // we shouldn't get here 
     181            } 
     182         
    169183            // if a template is defined, load the template,  
    170184            if (isset($panel['template'])) $template->display($panel['template']); 
    171  
    172             // restore the template directory if needed 
    173             $template->template_dir = PATH_THEME.'templates/source'; 
     185             
     186            // restore the template direcory if needed 
     187            if (isset($td) && is_array($td)) $template->template_dir = $td; 
    174188        } 
    175189    } 
Note: See TracChangeset for help on using the changeset viewer.