Ignore:
Timestamp:
Jul 14, 2008, 11:42:40 PM (16 years ago)
Author:
vdigital
Message:

Feature template-extension based on 2006 chrisaga's idea.
chrisaga wrote: "If you want to make some template customization without building a brand new
template, you should use ..."

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/template.class.php

    r2334 r2434  
    146146  function set_filenames($filename_array)
    147147  {
     148    global $conf;
    148149    if (!is_array($filename_array))
    149150    {
    150151      return false;
    151152    }
    152 
    153153    reset($filename_array);
     154    $tpl_extension = isset($conf['extents_for_templates']) ?
     155      unserialize($conf['extents_for_templates']) : array();
    154156    while(list($handle, $filename) = each($filename_array))
    155157    {
     
    157159        unset( $this->files[$handle] );
    158160      else
    159         $this->files[$handle] = $filename;
     161      {
     162        if (!isset($this->files[$handle])) $this->files[$handle] = $filename;
     163        foreach ($tpl_extension as $file => $conditions)
     164        {
     165          $localtpl = './template-extension/' . $file;
     166          if ($handle == $conditions[0] and
     167             (stripos(implode('/',array_flip($_GET)),$conditions[1])>0
     168              or $conditions[1] == 'N/A')
     169              and file_exists($localtpl))
     170          { /* examples: Are best_rated, created-monthly-calendar, list, ... set? */
     171              $this->files[$handle] = '../.' . $localtpl;
     172              /* assign their tpl-extension */
     173              /* For test purpose: Do advanced users need a php access? */
     174              // $localphp = '../.' . substr($localtpl,0,-3).'php';
     175              // if (file_exists($localphp)) @include_once($localphp);
     176          }
     177        }
     178      }
    160179    }
    161180    return true;
    162181  }
    163 
     182  function on_extension($key, $tlpname)
     183  {
     184    return $tplname;
     185  }
    164186  /** see smarty assign http://www.smarty.net/manual/en/api.assign.php */
    165187  function assign($tpl_var, $value = null)
Note: See TracChangeset for help on using the changeset viewer.