What is Smarty?
Why use it?
Use Cases and Work Flow
Syntax Comparison
Template Inheritance
Best Practices
Crash Course
You may use the Smarty logo according to the trademark notice.
For sponsorship, advertising, news or other inquiries, contact us at:
Smarty comes with several built-in functions. These built-in functions are the integral part of the smarty template engine. You cannot create your own custom functions with the same name; and you should not need to modify the built-in functions.
A few of these functions have an assign attribute which collects the result the function to a named template variable instead of being output; much like the {assign} function.
{capture} dipakai untuk mengumpulkan output template antara tag ke dalam variable daripada menampilkannya. Setiap konten antara {capture name='foo'} dan {/capture} yang dikumpulkan ke dalam variabel ditetapkan dalam atribut name.
Konten yang ditangkap dapat digunakan dalam template dari variabel $smarty.capture.foo di mana "foo" adalah nilai yang dikirimkan dalam atribut name. Jika anda tidak menyertakan atribut name, maka "default" akan dipakai sebagai nama misalnya $smarty.capture.default.
{capture}'s dapat diulang-ulang.
Attribute Name | Type | Required | Default | Description |
---|---|---|---|---|
name | string | no | default | The name of the captured block |
assign | string | No | n/a | The variable name where to assign the captured output to |
Perhatian: Harap berhati-hati ketika menangkap output {insert}. Jika anda menghidupkan $caching dan anda mempunyai perintah {insert} yang anda harapkan untuk dijalankan di dalam konten yang di-cache, jangan menangkap konten ini.
Teladan 7-2. {capture} ke dalam variabel template Contoh ini juga memperlihatkan fungsi {popup}
|
Lihat juga $smarty.capture, {eval}, {fetch}, fetch() dan {assign}.