Get Smarty

Donate

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

Buy cheap glasses from Cheapglasses123.com and save up to 80%.

Where to buy prescription glasses? EyewearCanada.com is your best choice!

Where to buy discount wedding dresses and cheap smart dresses free shipping - Weddingdresstrend.com

Shop for 2018 World Cup Football Boots Online sale at guthjcc.com

Browse best 2018 world cup soccer cleats and shoes from SoccerAzteca.com

Advertisement

编写插件

插件可以让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.
Post a Comment
All comments are moderated. Support questions are ignored, use the forums instead.
Author:
Email: (not shown)
What is 17 plus 0? (Are you human?)

Advertisement