Chapter 7. Built-in Functions[������.�ڽ�����]

Table of Contents
capture
config_load
foreach,foreachelse
include
include_php
insert
if,elseif,else
ldelim,rdelim
literal
php
section,sectionelse
strip

Smarty comes with several built-in functions.
Built-in functions are integral to the template language.
You cannot create custom functions with the same names, nor can you modify built-in functions.

Smarty�Դ��ܶ��ڽ�����.
�ڽ�������ģ�����Ե�һ����.
�㲻���Զ������ƺ��ڽ�����һ�����Զ��庯��,Ҳ���������޸��ڽ�����.

capture

capture is used to collect the output of the template into a variable instead of displaying it.
Any content between {capture name="foo"} and {/capture} is collected into the variable specified in the name attribute.
The captured content can be used in the template from the special variable $smarty.
capture.foo where foo is the value passed in the name attribute. If you do not supply a name attribute, then "default" will be used.
All {capture} commands must be paired with {/capture}. You can nest capture commands.

capture�������������ռ�ģ����������ݵ�һ��������,�����ǰ����������ҳ��.
�κ��� {capture name="foo"}��{/capture}֮������ݶ����յ����ɺ�������������ָ���ı�����($foo).
�ռ�����Ϣ���������������$smarty��.
����capture.foo���ռ�����������.�������û����������,��ʹ��"default".
ÿ��{capture}�������Ӧ{/capture},Ҳ����Ƕ��ʹ��capture����

Technical Note:
Smarty 1.4.0 - 1.4.4 placed the captured content into the variable named $return.
As of 1.4.5, this behavior was changed to use the name attribute, so update your templates accordingly.

������ʾ:
Smarty 1.4.0 - 1.4.4���ռ������ݷŵ���$return������.
��1.4.5�Ժ���ռ�������������ָ���ı�����.���������ģ��

Caution

Be careful when capturing {insert} output. If you have caching turned on and you have {insert} commands that you expect to run within cached content, do not capture this content.


����

��ץȡ{insert} �������ʱ����С��.�������˻��沢ָ�� {insert} ָ�������ڻ����������,��Ҫץȡ��Щ����.

Example 7-1. capturing template content
�� 7-1.ץȡģ������

{* we don't want to print a table row unless content is displayed *}

{* ���Dz�����û�����ݵ�ʱ������յı��� *}



{capture name=banner}

{include file="get_banner.tpl"}

{/capture}

{if $smarty.capture.banner ne ""}

	<tr>

		<td>

			{$smarty.capture.banner}

		</td>

	</tr>

{/if}