Get Smarty

Donate

Donate Bitcoin Bitcoin
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

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

Buy prescription glasses from www.australiaglasses.com and save.

Cheap Glasses Now On Sale at GlassesPeople.com. Starts At $7.95.

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

Brautkleider auf Topwedding.de

Find free files to download on allwhatyouwant.net

Looking For Affordable Wedding Dresses 2015 at Best Prices On TDBridal.com

Shop high quality cheap prom dresses on Dresswe.co.uk

Buy New Arrival Cheap Prom Dresses 2015 at JDBRIDAL Prom Dress Store

Advertisement

Chapter 18. 以插件扩展Smarty

Smarty 2.0引入的插件架构,已经成为了Smarty最常使用的自定义功能了。 插件包含了:

  • functions
  • modifiers
  • block functions
  • compiler functions
  • prefilters
  • postfilters
  • outputfilters
  • resources
  • inserts

除了资源插件以外,为了向上兼容还是保留了通过register_* API来注册插件的方式。 如果你不是使用API方式而是使用直接修改$custom_funcs, $custom_mods等方式,那么你需要调整你的代码,改为通过API方式或 转换成自定义插件。

插件如何工作

插件是按需载入的。当特定的修饰器,函数,资源等被调用的时候插件才会被载入。 而且,即使同一请求中有多个Smarty实例在运行,每个资源也只会被载入一次。

前置/后置过滤器和输出过滤器稍微有些不同。 虽然它们并没有在模板中使用,但是当模板执行的时候,它们必须通过API被注册或者被明确载入。 相同类型的过滤器执行的顺序会依据它们注册或载入的先后顺序。

插件目录变量可以是一个路径的字符串或者是包含多个路径的数组。 安装插件的方法是直接把插件文件放置在这些目录下,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 0 plus 2? (Are you human?)

Advertisement