命名规则

插件文件和函数必须遵循特定的命名规则以便Smarty识别。

插件文件命名规则:

type.name.php

  • 其中type是以下任一种插件类型:

    • function
    • modifier
    • block
    • compiler
    • prefilter
    • postfilter
    • outputfilter
    • resource
    • insert

  • name必须是合法的函数名(仅包括字母、数字和下划线),参考 php variables

  • 例如: function.html_select_date.php, resource.db.php, modifier.spacify.php.

PHP文件内的插件函数命名规则:

smarty_type, _name

  • typename规则同上。

  • 例如一个修饰器名称为 foo,函数名就是 function smarty_modifier_foo()

当找不到插件文件,或者文件/插件函数的命名不恰当的时候,Smarty将提示错误信息。