?
本文檔使用 PHP中文網(wǎng)手冊(cè) 發(fā)布
Plugins can be either loaded by Smarty automatically from the filesystem or they can be registered at runtime via one of the register_* API functions. They can also be unregistered by using unregister_* API functions.
Smarty可自動(dòng)從文件系統(tǒng)裝載插件,或者運(yùn)行時(shí)通過register_* API函數(shù)裝載。 可以通過unregister_* API函數(shù)卸載已經(jīng)裝載的插件。
For the plugins that are registered at runtime, the name of the plugin function(s) does not have to follow the naming convention.
只在運(yùn)行時(shí)裝載的插件的函數(shù)名稱不需要遵守命名約定。
If a plugin depends on some functionality provided by another plugin (as is the case with some plugins bundled with Smarty), then the proper way to load the needed plugin is this:
如果某個(gè)插件依賴其它插件內(nèi)的某些功能(例如某些插件功能捆綁于Smarty內(nèi)),那么可以通過如下方法裝載必須的插件:
require_once $smarty->_get_plugin_filepath('function', 'html_options'); |
As a general rule, Smarty object is always passed to the plugins as the last parameter (with two exceptions: modifiers do not get passed the Smarty object at all and blocks get passed &$repeat after the Smarty object to keep backwards compatibility to older versions of Smarty).
Smarty對(duì)象通常作為傳遞給插件的最后一個(gè)參數(shù)(有兩個(gè)例外:1、修飾插件根本不接受傳遞過來的Smarty對(duì)象。2、為了向上兼容老版本的Smarty,區(qū)塊插件將 &$repeat 作為最后一個(gè)參數(shù),因此Smarty對(duì)象是倒數(shù)第二個(gè)參數(shù)。)