| |
The templates may come from a variety of sources. When you display or fetch a template, or when you include a template from within another template, you supply a resource type, followed by the appropriate path and template name.
Templates from the $template_dir do not require a template resource, although you can use the file: resource for consistancy. Just supply the path to the template you want to use relative to the $template_dir root directory.
Templates outside of the $template_dir require the file: template resource type, followed by the absolute path and name of the template.
You can retrieve templates using whatever possible source you can access with PHP: databases, sockets, LDAP, and so on. You do this by writing resource plugin functions and registering them with Smarty.
See resource plugins section for more information on the functions you are supposed to provide.
Замечание: Note that you cannot override the built-in file resource, but you can provide a resource that fetches templates from the file system in some other way by registering under another resource name.
Пример 15-9. using custom resources
|
You can specify a function that is used to retrieve template contents in the event the template cannot be retrieved from its resource. One use of this is to create templates that do not exist on-the-fly.
Пример 15-10. using the default template handler function
|
Пред. | Начало | След. |
Cache Handler Function | Уровень выше | Extending Smarty With Plugins |
Закладки на сайте Проследить за страницей |
Created 1996-2024 by Maxim Chirkov Добавить, Поддержать, Вебмастеру |