💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
<table summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0"><tr><th colspan="3" align="center">Smarty - the compiling PHP template engine</th></tr><tr><td width="25%" align="left" valign="bottom"><a href="plugins.html" accesskey="P">Prev</a></td><td width="50%" align="center" valign="bottom">Chapter 16. Extending Smarty With Plugins</td><td width="25%" align="right" valign="bottom"><a href="plugins.writing.html" accesskey="N">Next</a></td></tr></table> # How Plugins Work [插件如何工作] Plugins are always loaded on demand. Only the specific modifiers, functions, resources, etc invoked in the templates scripts will be loaded. Moreover, each plugin is loaded only once, even if you have several different instances of Smarty running within the same request. Pre/postfilters and output filters are a bit of a special case. Since they are not mentioned in the templates, they must be registered or loaded explicitly via API functions before the template is processed. The order in which multiple filters of the same type are executed depends on the order in which they are registered or loaded. The plugins directory can be a string containing a path or an array containing multiple paths. To install a plugin, simply place it in one of the directories and Smarty will use it automatically. 插件总是按需加载。只有在模板脚本中调用特定的调节器、函数、资源插件等时才会自动加载。此外,每个插件只加载一次,即便在同一个请求中存在几个不同的Smarty实例同时运行。 预/后过滤器插件和输出过滤器插件的加载方式有点例外。由于它们未涉及在模板中直接使用(上述三个插件都是在php代码中处理的),它们必须在模板处理前通过注册或API函数明确地载入系统。同类型的多重过滤器的执行顺序取决于它们被注册或载入的先后次序。 插件目录可以是一个包含路径的字符串或包含多个路径的数组。安装插件的时候,将插件简单地置于其中一个目录下,Smarty会自动识别使用。 <table summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0"><tr><td width="33%" align="left" valign="top"><a href="plugins.html" accesskey="P">Prev</a></td><td width="34%" align="center" valign="top"><a href="index.html" accesskey="H">Home</a></td><td width="33%" align="right" valign="top"><a href="plugins.writing.html" accesskey="N">Next</a></td></tr><tr><td width="33%" align="left" valign="top">Extending Smarty With Plugins 以插件扩展Smarty</td><td width="34%" align="center" valign="top"><a href="plugins.html" accesskey="U">Up</a></td><td width="33%" align="right" valign="top">Naming Conventions<br/> 命名约定</td></tr></table>