Writing Plugins編寫插件

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可自動從文件系統裝載插件,或者運行時通過register_* API函數裝載。可以通過unregister_* API函數卸載已經裝載的插件。

For the plugins that are registered at runtime, the name of the plugin function(s) does not have to follow the naming convention.

只在運行時裝載的插件的函數名稱不需要遵守命名約定。

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:

如果某個插件依賴其它插件內的某些功能(例如某些插件功能捆綁於Smarty內),那麼可以通過如下方法裝載必須的插件:

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對象通常作爲傳遞給插件的最後一個參數(有兩個例外:1、修飾插件根本不接受傳遞過來的Smarty對象。2、爲了向上兼容老版本的Smarty,區塊插件將 &$repeat 作爲最後一個參數,因此Smarty對象是倒數第二個參數。)  

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章