1 <?php
3 /**
4 * Smarty method Register_Block
5 *
6 * Registers a PHP function as Smarty block function plugin
7 *
8 * @package Smarty
9 * @subpackage SmartyMethod
10 * @author Uwe Tews
11 */
13 /**
14 * Register a PHP function as Smarty block function plugin
15 */
17 /**
18 * Registers block function to be used in templates
19 *
20 * @param string $block_tag name of template block
21 * @param string $block_impl PHP function to register
22 * @param boolean $cacheable if true (default) this fuction is cachable
23 */
24 function Smarty_Method_Register_Block($smarty, $block_tag, $block_impl, $cacheable = true, $cache_attr = array())
25 {
26 if (isset($smarty->registered_plugins['block'][$block_tag])) {
27 throw new Exception("Plugin tag \"{$block_tag}\" already registered");
28 } elseif (!is_callable($block_impl)) {
29 throw new Exception("Plugin \"{$block_tag}\" not callable");
30 } else {
31 $smarty->registered_plugins['block'][$block_tag] =
32 array($block_impl, $cacheable, $cache_attr);
33 }
34 }
36 ?>