?
Dieses Dokument verwendet PHP-Handbuch für chinesische Websites Freigeben
Version 2.0 introduced the plugin architecture that is used for almost all the customizable functionality of Smarty. This includes:
2.0版本引入了被廣泛應用于自定義Smarty功能的插件機制。它包括如下類型:
為了與舊有方式保持向后兼容,除資源插件外,保留了通過register_* API方式裝載函數(shù)的 處理方法。如果你不是使用API方式而是使用直接修改類變量 $custom_funcs, $custom_mods 等的方法,那么你就需要修改你的程序了?;蛘呤褂肁PI的方法,或者將你的自定義功能轉(zhuǎn)換成插件。
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.
插件總在需要的時候被裝載。只有在模板腳本里調(diào)用的特定修飾、函數(shù)、資源插件等會被裝載。此外,即便在同一個請求中有幾個不同的Smarty實體運行,每個插件也只被裝載一次。
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.
預/補過濾器插件和輸出過濾器插件的裝載方式有些不同。由于在模板中未被提及,它們必須在模板被處理前通過API函數(shù)明確地裝入系統(tǒng)。同類型的多個過濾器插件依據(jù)被裝載的次序先后不同分別先后執(zhí)行。
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.
插件目錄是包含一條路徑信息的字符串或包含多條路徑信息的字符串數(shù)組。安裝插件的時候,將插件置于其中一個目錄下,Smarty會自動識別使用。