Get Smarty

Donate

Paypal

Smarty Icon

You may use the Smarty logo according to the trademark notice.

Smarty Template Engine Smarty Template Engine

For sponsorship, advertising, news or other inquiries, contact us at:

Sites Using Smarty

Advertisement

Get the juciest casino bonuses at this great website

If you are looking for great entertainment online, then we would like to recommend CasinoAdvisers.com. Find the best casino bonus available and much more that makes your casino experience much more enjoyable!

编写插件

插件可以让Smarty自动载入,或通过register_* API函数在运行时进行注册。 它们还可以通过unregister_* API函数来注销。

当插件是运行时注册的,插件的名称不一定需要遵循下面的命名规则。

如果插件依赖与其他插件提供的功能时(如依赖与一些Smarty自带的插件), 比较好的方法是像下面这样载入需要的插件:


<?php
function smarty_function_yourPlugin(array $params, Smarty_Internal_Template $template)
{
  // 载入依赖的插件
  $template->smarty->loadPlugin('smarty_shared_make_timestamp');
  // 插件代码
}
?>

    

一般而言,Smarty_Internal_Template对象将作为插件的最后一个参数传递, 除了两种例外情况:

  • 修饰器完全不接受Smarty_Internal_Template对象。

  • 为了向上兼容老版本的Smarty,区块插件将 $repeat 作为最后一个参数,因此Smarty对象是倒数第二个参数。

Comments
No comments for this page.

Advertisement