Changeset 2712 for trunk/include


Ignore:
Timestamp:
Oct 11, 2008, 2:55:43 PM (16 years ago)
Author:
patdenice
Message:
  • Add known_template function (maybe we can change function name).
  • Template extensions are working with menubar blocks templates.
File:
1 edited

Legend:

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

    r2699 r2712  
    6767    $this->smarty->register_block('html_head', array(&$this, 'block_html_head') );
    6868    $this->smarty->register_function('known_script', array(&$this, 'func_known_script') );
     69    $this->smarty->register_function('known_template', array(&$this, 'func_known_template') );
    6970    $this->smarty->register_prefilter( array('Template', 'prefilter_white_space') );
    7071    if ( $conf['compiled_template_cache_language'] )
     
    409410  }
    410411
     412 /**
     413   * This smarty "known_template" functions allows to include template
     414   * If extent[$params['id']] exists, include template extension
     415   * else include $params[$file]
     416   */ 
     417  function func_known_template($params, &$smarty )
     418  {
     419    if (!isset($params['file']))
     420    {
     421      $smarty->trigger_error("known_template: missing 'file' parameter");
     422      return;
     423    }
     424
     425    if (isset($params['id']) and isset($this->extents[$params['id']]))
     426    {
     427      $file = $this->extents[$params['id']];
     428    }
     429    else
     430    {
     431      $file = $params['file'];
     432    }
     433
     434    return $smarty->_smarty_include(array(
     435             'smarty_include_tpl_file' => $file,
     436             'smarty_include_vars' => array()
     437             ));
     438  }
     439
    411440  static function prefilter_white_space($source, &$smarty)
    412441  {
Note: See TracChangeset for help on using the changeset viewer.