mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-15 23:19:25 +01:00
568 lines
17 KiB
XML
568 lines
17 KiB
XML
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
|||
|
|
<!-- $Revision$ -->
|
|||
|
|
<sect1 id="language.function.section">
|
|||
|
|
<title>section,sectionelse</title>
|
|||
|
|
<informaltable frame="all">
|
|||
|
|
<tgroup cols="5">
|
|||
|
|
<colspec colname="param" align="center" />
|
|||
|
|
<colspec colname="type" align="center" />
|
|||
|
|
<colspec colname="required" align="center" />
|
|||
|
|
<colspec colname="default" align="center" />
|
|||
|
|
<colspec colname="desc" />
|
|||
|
|
<thead>
|
|||
|
|
<row>
|
|||
|
|
<entry>Nome do atributo</entry>
|
|||
|
|
<entry>Tipo</entry>
|
|||
|
|
<entry>Requerido</entry>
|
|||
|
|
<entry>Padr<EFBFBD>o</entry>
|
|||
|
|
<entry>Descri<EFBFBD><EFBFBD>o</entry>
|
|||
|
|
</row>
|
|||
|
|
</thead>
|
|||
|
|
<tbody>
|
|||
|
|
<row>
|
|||
|
|
<entry>name</entry>
|
|||
|
|
<entry>string</entry>
|
|||
|
|
<entry>Sim</entry>
|
|||
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|||
|
|
<entry>O nome da se<73><65>o</entry>
|
|||
|
|
</row>
|
|||
|
|
<row>
|
|||
|
|
<entry>loop</entry>
|
|||
|
|
<entry>[$variable_name]</entry>
|
|||
|
|
<entry>Sim</entry>
|
|||
|
|
<entry><emphasis>n/a</emphasis></entry>
|
|||
|
|
<entry>O nome da vari<72>vel para determinar o
|
|||
|
|
n<>mero de intera<72><61>es</entry>
|
|||
|
|
</row>
|
|||
|
|
<row>
|
|||
|
|
<entry>start</entry>
|
|||
|
|
<entry>integer</entry>
|
|||
|
|
<entry>N<EFBFBD>o</entry>
|
|||
|
|
<entry><emphasis>0</emphasis></entry> <entry>A posi<73><69>o
|
|||
|
|
do <20>ndice que a se<73><65>o vai come<6D>ar. Se o valor
|
|||
|
|
<09> negativo, a posi<73><69>o de inicio <20> calculada a partir
|
|||
|
|
do final da matriz. For exemplo, se houverem
|
|||
|
|
sete valores na matriz e start for -2, o
|
|||
|
|
<09>ndice inicial <20> 5. Valores inv<6E>lidos (valores fora do
|
|||
|
|
tamanho da matriz) s<>o automaticamente truncados
|
|||
|
|
para o valor v<>lido mais pr<70>ximo.</entry>
|
|||
|
|
</row>
|
|||
|
|
<row>
|
|||
|
|
<entry>step</entry>
|
|||
|
|
<entry>integer</entry>
|
|||
|
|
<entry>N<EFBFBD>o</entry>
|
|||
|
|
<entry><emphasis>1</emphasis></entry>
|
|||
|
|
<entry>O valor do passo que ser<65> usado para o loop
|
|||
|
|
na matriz. Por exemplo, step=2 ir<69> realizar o loop com
|
|||
|
|
os <20>ndices 0,2,4, etc. Se step for negativo, ele ir<69> caminhar
|
|||
|
|
pela matriz de tr<74>s para frente.</entry>
|
|||
|
|
</row>
|
|||
|
|
<row>
|
|||
|
|
<entry>max</entry>
|
|||
|
|
<entry>integer</entry>
|
|||
|
|
<entry>N<EFBFBD>o</entry>
|
|||
|
|
<entry><emphasis>1</emphasis></entry>
|
|||
|
|
<entry>Define o n<>mero m<>ximo de loops
|
|||
|
|
para a section.</entry>
|
|||
|
|
</row>
|
|||
|
|
<row>
|
|||
|
|
<entry>show</entry>
|
|||
|
|
<entry>boolean</entry>
|
|||
|
|
<entry>N<EFBFBD>o</entry>
|
|||
|
|
<entry><emphasis>true</emphasis></entry>
|
|||
|
|
<entry>Determina quando mostrar ou n<>o esta section</entry>
|
|||
|
|
</row>
|
|||
|
|
</tbody>
|
|||
|
|
</tgroup>
|
|||
|
|
</informaltable>
|
|||
|
|
<para>
|
|||
|
|
sections de template s<>o usada para realizar um loop por uma matriz. Todas as tags
|
|||
|
|
<emphasis>section</emphasis> devem ter as suas
|
|||
|
|
<emphasis>/section</emphasis>. Par<61>metros requeridos s<>o
|
|||
|
|
<emphasis>name</emphasis> e <emphasis>loop</emphasis>. O nome
|
|||
|
|
de section pode ser o que voc<6F> quiser, feito de letras,
|
|||
|
|
n<>meros e sublinhados. Sections podem ser aninhadas, e os nomes das section
|
|||
|
|
aninhadas devem ser diferentes um dos outros. A vari<72>vel do loop
|
|||
|
|
(normalmente uma matriz de valores) determina o n<>mero de vezes do
|
|||
|
|
loop da section. Quando estiver mostrando uma vari<72>vel dentro de uma section,
|
|||
|
|
o nome da section deve estar ao lado da vari<72>vel dentro de conchetes
|
|||
|
|
[]. <emphasis>sectionelse</emphasis> <20>
|
|||
|
|
executado quando n<>o houverem valores para a vari<72>vel de loop.
|
|||
|
|
</para>
|
|||
|
|
<example>
|
|||
|
|
<title>section</title>
|
|||
|
|
<programlisting>
|
|||
|
|
|
|||
|
|
{* este exemplo ir<69> mostrar todos os valores de $custid array *}
|
|||
|
|
{section name=customer loop=$custid}
|
|||
|
|
id: {$custid[customer]}<br>
|
|||
|
|
{/section}
|
|||
|
|
|
|||
|
|
MOSTRA:
|
|||
|
|
|
|||
|
|
id: 1000<br>
|
|||
|
|
id: 1001<br>
|
|||
|
|
id: 1002<br></programlisting>
|
|||
|
|
</example>
|
|||
|
|
|
|||
|
|
<example>
|
|||
|
|
<title>loop de vari<72>vel section</title>
|
|||
|
|
<programlisting>
|
|||
|
|
{* a vari<72>vel de loo<6F>p determina o n<>mero de vezes do loop.
|
|||
|
|
Voc<6F> pode acessar qualquer vari<72>vel do template dentro da section.
|
|||
|
|
Este exemplo assume que $custid, $name e $address s<>o todas
|
|||
|
|
matrizes contendo o mesmo n<>mero de valores *}
|
|||
|
|
{section name=customer loop=$custid}
|
|||
|
|
id: {$custid[customer]}<br>
|
|||
|
|
name: {$name[customer]}<br>
|
|||
|
|
address: {$address[customer]}<br>
|
|||
|
|
<p>
|
|||
|
|
{/section}
|
|||
|
|
|
|||
|
|
|
|||
|
|
MOSTRA:
|
|||
|
|
|
|||
|
|
id: 1000<br>
|
|||
|
|
name: John Smith<br>
|
|||
|
|
address: 253 N 45th<br>
|
|||
|
|
<p>
|
|||
|
|
id: 1001<br>
|
|||
|
|
name: Jack Jones<br>
|
|||
|
|
address: 417 Mulberry ln<br>
|
|||
|
|
<p>
|
|||
|
|
id: 1002<br>
|
|||
|
|
name: Jane Munson<br>
|
|||
|
|
address: 5605 apple st<br>
|
|||
|
|
<p></programlisting>
|
|||
|
|
</example>
|
|||
|
|
|
|||
|
|
<example>
|
|||
|
|
<title>Nomes de section</title>
|
|||
|
|
<programlisting>
|
|||
|
|
{* o nome de section pode ser o que voc<6F> quiser,
|
|||
|
|
e <20> usado para referenciar os dados dentro da section *}
|
|||
|
|
{section name=mydata loop=$custid}
|
|||
|
|
id: {$custid[mydata]}<br>
|
|||
|
|
name: {$name[mydata]}<br>
|
|||
|
|
address: {$address[mydata]}<br>
|
|||
|
|
<p>
|
|||
|
|
{/section}</programlisting>
|
|||
|
|
</example>
|
|||
|
|
|
|||
|
|
<example>
|
|||
|
|
<title>sections aninhadas</title>
|
|||
|
|
<programlisting>
|
|||
|
|
{* sections podem ser aninhadas t<>o profundamente quanto voc<6F> quiser. Com sections aninhadas,
|
|||
|
|
voc<6F> pode acessar estruturas de dados complexas, como matriz multi-dimensionais.
|
|||
|
|
Neste exemplo, $contact_type[customer] <20> uma matriz de
|
|||
|
|
tipos de contato para o custumer atual. *}
|
|||
|
|
{section name=customer loop=$custid}
|
|||
|
|
id: {$custid[customer]}<br>
|
|||
|
|
name: {$name[customer]}<br>
|
|||
|
|
address: {$address[customer]}<br>
|
|||
|
|
{section name=contact loop=$contact_type[customer]}
|
|||
|
|
{$contact_type[customer][contact]}: {$contact_info[customer][contact]}<br>
|
|||
|
|
{/section}
|
|||
|
|
<p>
|
|||
|
|
{/section}
|
|||
|
|
|
|||
|
|
|
|||
|
|
MOSTRA:
|
|||
|
|
|
|||
|
|
id: 1000<br>
|
|||
|
|
name: John Smith<br>
|
|||
|
|
address: 253 N 45th<br>
|
|||
|
|
home phone: 555-555-5555<br>
|
|||
|
|
cell phone: 555-555-5555<br>
|
|||
|
|
e-mail: john@mydomain.com<br>
|
|||
|
|
<p>
|
|||
|
|
id: 1001<br>
|
|||
|
|
name: Jack Jones<br>
|
|||
|
|
address: 417 Mulberry ln<br>
|
|||
|
|
home phone: 555-555-5555<br>
|
|||
|
|
cell phone: 555-555-5555<br>
|
|||
|
|
e-mail: jack@mydomain.com<br>
|
|||
|
|
<p>
|
|||
|
|
id: 1002<br>
|
|||
|
|
name: Jane Munson<br>
|
|||
|
|
address: 5605 apple st<br>
|
|||
|
|
home phone: 555-555-5555<br>
|
|||
|
|
cell phone: 555-555-5555<br>
|
|||
|
|
e-mail: jane@mydomain.com<br>
|
|||
|
|
<p></programlisting>
|
|||
|
|
</example>
|
|||
|
|
|
|||
|
|
<example>
|
|||
|
|
<title>sections e matrizes associativas</title>
|
|||
|
|
<programlisting>
|
|||
|
|
{* Este <20> um exemplo de mostrar os dados de matriz associativa
|
|||
|
|
dentro da section *}
|
|||
|
|
{section name=customer loop=$contacts}
|
|||
|
|
name: {$contacts[customer].name}<br>
|
|||
|
|
home: {$contacts[customer].home}<br>
|
|||
|
|
cell: {$contacts[customer].cell}<br>
|
|||
|
|
e-mail: {$contacts[customer].email}<p>
|
|||
|
|
{/section}
|
|||
|
|
|
|||
|
|
|
|||
|
|
MOSTRA:
|
|||
|
|
|
|||
|
|
name: John Smith<br>
|
|||
|
|
home: 555-555-5555<br>
|
|||
|
|
cell: 555-555-5555<br>
|
|||
|
|
e-mail: john@mydomain.com<p>
|
|||
|
|
name: Jack Jones<br>
|
|||
|
|
home phone: 555-555-5555<br>
|
|||
|
|
cell phone: 555-555-5555<br>
|
|||
|
|
e-mail: jack@mydomain.com<p>
|
|||
|
|
name: Jane Munson<br>
|
|||
|
|
home phone: 555-555-5555<br>
|
|||
|
|
cell phone: 555-555-5555<br>
|
|||
|
|
e-mail: jane@mydomain.com<p></programlisting>
|
|||
|
|
</example>
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
<example>
|
|||
|
|
<title>sectionelse</title>
|
|||
|
|
<programlisting>
|
|||
|
|
{* sectionelse ir<69> executar se n<>o houverem mais valores $custid *}
|
|||
|
|
{section name=customer loop=$custid}
|
|||
|
|
id: {$custid[customer]}<br>
|
|||
|
|
{sectionelse}
|
|||
|
|
there are no values in $custid.
|
|||
|
|
{/section}</programlisting>
|
|||
|
|
</example>
|
|||
|
|
<para>
|
|||
|
|
Sections tamb<6D>m tem as suas pr<70>prias vari<72>veis que manipulam as propriedaes section.
|
|||
|
|
Estas s<>o indicadas assim: {$smarty.section.sectionname.varname}
|
|||
|
|
</para>
|
|||
|
|
<para>
|
|||
|
|
NOTA: a partir do Smarty 1.5.0, a sintaxe para as vari<72>veis de propriedades de section
|
|||
|
|
mudou de {%sectionname.varname%} para
|
|||
|
|
{$smarty.section.sectionname.varname}. A sintaxe antiga ainda <20> suportada,
|
|||
|
|
mas voc<6F> ir<69> ver referencias apenas a nova sintaxe nos
|
|||
|
|
exemplos do manual.
|
|||
|
|
</para>
|
|||
|
|
<sect2 id="section.property.index">
|
|||
|
|
<title>index</title>
|
|||
|
|
<para>
|
|||
|
|
index <20> usado para mostrar o <20>ndice atual do loop, come<6D>ando em zero
|
|||
|
|
(ou pelo atributo start se dado), e incrementando por um (ou pelo
|
|||
|
|
atributo step se dado).
|
|||
|
|
</para>
|
|||
|
|
<note>
|
|||
|
|
<title>Nota T<>cnica</title>
|
|||
|
|
<para>
|
|||
|
|
Se as propriedades section n<>o for modificada,
|
|||
|
|
ent<6E>o isto funciona igual a propriedade iteration da section,
|
|||
|
|
exceto que come<6D>a em 0 ao inv<6E>s de 1.
|
|||
|
|
</para>
|
|||
|
|
</note>
|
|||
|
|
<example>
|
|||
|
|
<title>section property index</title>
|
|||
|
|
<programlisting>
|
|||
|
|
{section name=customer loop=$custid}
|
|||
|
|
{$smarty.section.customer.index} id: {$custid[customer]}<br>
|
|||
|
|
{/section}
|
|||
|
|
|
|||
|
|
|
|||
|
|
MOSTRA:
|
|||
|
|
|
|||
|
|
0 id: 1000<br>
|
|||
|
|
1 id: 1001<br>
|
|||
|
|
2 id: 1002<br>
|
|||
|
|
</programlisting>
|
|||
|
|
</example>
|
|||
|
|
</sect2>
|
|||
|
|
<sect2 id="section.property.index.prev">
|
|||
|
|
<title>index_prev</title>
|
|||
|
|
<para>
|
|||
|
|
index_prev <20> usado para mostrar o <20>ndice anterior do loop.
|
|||
|
|
No primeiro loop, isto <20> definido como -1.
|
|||
|
|
</para>
|
|||
|
|
<example>
|
|||
|
|
<title>section property index_prev</title>
|
|||
|
|
<programlisting>
|
|||
|
|
{section name=customer loop=$custid}
|
|||
|
|
{$smarty.section.customer.index} id: {$custid[customer]}<br>
|
|||
|
|
{* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *}
|
|||
|
|
{if $custid[customer.index_prev] ne $custid[customer.index]}
|
|||
|
|
The customer id changed<br>
|
|||
|
|
{/if}
|
|||
|
|
{/section}
|
|||
|
|
|
|||
|
|
|
|||
|
|
MOSTRA:
|
|||
|
|
|
|||
|
|
0 id: 1000<br>
|
|||
|
|
The customer id changed<br>
|
|||
|
|
1 id: 1001<br>
|
|||
|
|
The customer id changed<br>
|
|||
|
|
2 id: 1002<br>
|
|||
|
|
The customer id changed<br>
|
|||
|
|
</programlisting>
|
|||
|
|
</example>
|
|||
|
|
</sect2>
|
|||
|
|
<sect2 id="section.property.index.next">
|
|||
|
|
<title>index_next</title>
|
|||
|
|
<para>
|
|||
|
|
index_next <20> usado para mostrar o pr<70>ximo indice do loop. No <20>ltimo loop,
|
|||
|
|
isto ainda <20> um mais o <20>ndice atual( respeitando a defini<6E><69>o
|
|||
|
|
do atributo step, se dado.)
|
|||
|
|
</para>
|
|||
|
|
<example>
|
|||
|
|
<title>section property index_next</title>
|
|||
|
|
<programlisting>
|
|||
|
|
{section name=customer loop=$custid}
|
|||
|
|
{$smarty.section.customer.index} id: {$custid[customer]}<br>
|
|||
|
|
{* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *}
|
|||
|
|
{if $custid[customer.index_next] ne $custid[customer.index]}
|
|||
|
|
The customer id will change<br>
|
|||
|
|
{/if}
|
|||
|
|
{/section}
|
|||
|
|
|
|||
|
|
|
|||
|
|
MOSTRA:
|
|||
|
|
|
|||
|
|
0 id: 1000<br>
|
|||
|
|
The customer id will change<br>
|
|||
|
|
1 id: 1001<br>
|
|||
|
|
The customer id will change<br>
|
|||
|
|
2 id: 1002<br>
|
|||
|
|
The customer id will change<br>
|
|||
|
|
</programlisting>
|
|||
|
|
</example>
|
|||
|
|
</sect2>
|
|||
|
|
<sect2 id="section.property.iteration">
|
|||
|
|
<title>iteration</title>
|
|||
|
|
<para>
|
|||
|
|
iteration <20> usado para mostrar a intera<72><61>o atual do loop.
|
|||
|
|
</para>
|
|||
|
|
<para>
|
|||
|
|
NOTA: isto n<>o <20> afetado pelas propriedades start, step e
|
|||
|
|
max, diferentemente das propriedade index. Iteration tamb<6D>m come<6D>a com 1
|
|||
|
|
ao inv<6E>s de 0 como index. rownum <20> um apelido para iteration,
|
|||
|
|
elas funcionam de modo identico.
|
|||
|
|
</para>
|
|||
|
|
<example>
|
|||
|
|
<title>section property iteration</title>
|
|||
|
|
<programlisting>
|
|||
|
|
{section name=customer loop=$custid start=5 step=2}
|
|||
|
|
current loop iteration: {$smarty.section.customer.iteration}<br>
|
|||
|
|
{$smarty.section.customer.index} id: {$custid[customer]}<br>
|
|||
|
|
{* FYI, $custid[customer.index] and $custid[customer] are identical in meaning *}
|
|||
|
|
{if $custid[customer.index_next] ne $custid[customer.index]}
|
|||
|
|
The customer id will change<br>
|
|||
|
|
{/if}
|
|||
|
|
{/section}
|
|||
|
|
|
|||
|
|
|
|||
|
|
MOSTRA:
|
|||
|
|
|
|||
|
|
current loop iteration: 1
|
|||
|
|
5 id: 1000<br>
|
|||
|
|
The customer id will change<br>
|
|||
|
|
current loop iteration: 2
|
|||
|
|
7 id: 1001<br>
|
|||
|
|
The customer id will change<br>
|
|||
|
|
current loop iteration: 3
|
|||
|
|
9 id: 1002<br>
|
|||
|
|
The customer id will change<br>
|
|||
|
|
</programlisting>
|
|||
|
|
</example>
|
|||
|
|
</sect2>
|
|||
|
|
<sect2 id="section.property.first">
|
|||
|
|
<title>first</title>
|
|||
|
|
<para>
|
|||
|
|
first <20> definido como true se a intera<72><61>o atual da section
|
|||
|
|
<20> a primeira.
|
|||
|
|
</para>
|
|||
|
|
<example>
|
|||
|
|
<title>section property first</title>
|
|||
|
|
<programlisting>
|
|||
|
|
{section name=customer loop=$custid}
|
|||
|
|
{if $smarty.section.customer.first}
|
|||
|
|
<table>
|
|||
|
|
{/if}
|
|||
|
|
|
|||
|
|
<tr><td>{$smarty.section.customer.index} id:
|
|||
|
|
{$custid[customer]}</td></tr>
|
|||
|
|
|
|||
|
|
{if $smarty.section.customer.last}
|
|||
|
|
</table>
|
|||
|
|
{/if}
|
|||
|
|
{/section}
|
|||
|
|
|
|||
|
|
|
|||
|
|
MOSTRA:
|
|||
|
|
|
|||
|
|
<table>
|
|||
|
|
<tr><td>0 id: 1000</td></tr>
|
|||
|
|
<tr><td>1 id: 1001</td></tr>
|
|||
|
|
<tr><td>2 id: 1002</td></tr>
|
|||
|
|
</table>
|
|||
|
|
</programlisting>
|
|||
|
|
</example>
|
|||
|
|
</sect2>
|
|||
|
|
<sect2 id="section.property.last">
|
|||
|
|
<title>last</title>
|
|||
|
|
<para>
|
|||
|
|
last <20> definido como true de a intera<72><61>o atual da
|
|||
|
|
section <20> a <20>ltima.
|
|||
|
|
</para>
|
|||
|
|
<example>
|
|||
|
|
<title>section property last</title>
|
|||
|
|
<programlisting>
|
|||
|
|
{section name=customer loop=$custid}
|
|||
|
|
{if $smarty.section.customer.first}
|
|||
|
|
<table>
|
|||
|
|
{/if}
|
|||
|
|
|
|||
|
|
<tr><td>{$smarty.section.customer.index} id:
|
|||
|
|
{$custid[customer]}</td></tr>
|
|||
|
|
|
|||
|
|
{if $smarty.section.customer.last}
|
|||
|
|
</table>
|
|||
|
|
{/if}
|
|||
|
|
{/section}
|
|||
|
|
|
|||
|
|
|
|||
|
|
MOSTRA:
|
|||
|
|
|
|||
|
|
<table>
|
|||
|
|
<tr><td>0 id: 1000</td></tr>
|
|||
|
|
<tr><td>1 id: 1001</td></tr>
|
|||
|
|
<tr><td>2 id: 1002</td></tr>
|
|||
|
|
</table>
|
|||
|
|
</programlisting>
|
|||
|
|
</example>
|
|||
|
|
</sect2>
|
|||
|
|
<sect2 id="section.property.rownum">
|
|||
|
|
<title>rownum</title>
|
|||
|
|
<para>
|
|||
|
|
rownum <20> usado para mostrar a intera<72><61>o atual do loop,
|
|||
|
|
come<6D>ando em um. <20> um apelido para iteration,
|
|||
|
|
elas funcionam de modo identico.
|
|||
|
|
</para>
|
|||
|
|
<example>
|
|||
|
|
<title>section property rownum</title>
|
|||
|
|
<programlisting>
|
|||
|
|
{section name=customer loop=$custid}
|
|||
|
|
{$smarty.section.customer.rownum} id: {$custid[customer]}<br>
|
|||
|
|
{/section}
|
|||
|
|
|
|||
|
|
|
|||
|
|
MOSTRA:
|
|||
|
|
|
|||
|
|
1 id: 1000<br>
|
|||
|
|
2 id: 1001<br>
|
|||
|
|
3 id: 1002<br>
|
|||
|
|
</programlisting>
|
|||
|
|
</example>
|
|||
|
|
</sect2>
|
|||
|
|
<sect2 id="section.property.loop">
|
|||
|
|
<title>loop</title>
|
|||
|
|
<para>
|
|||
|
|
loop <20> usado para mostrar o <20>ltimo n<>mero do <20>ndice do loop desta
|
|||
|
|
section. Isto pode ser usado dentro ou depois de section.
|
|||
|
|
</para>
|
|||
|
|
<example>
|
|||
|
|
<title>section property index</title>
|
|||
|
|
<programlisting>
|
|||
|
|
{section name=customer loop=$custid}
|
|||
|
|
{$smarty.section.customer.index} id: {$custid[customer]}<br>
|
|||
|
|
{/section}
|
|||
|
|
|
|||
|
|
There were {$smarty.section.customer.loop} customers shown above.
|
|||
|
|
|
|||
|
|
MOSTRA:
|
|||
|
|
|
|||
|
|
0 id: 1000<br>
|
|||
|
|
1 id: 1001<br>
|
|||
|
|
2 id: 1002<br>
|
|||
|
|
|
|||
|
|
There were 3 customers shown above.
|
|||
|
|
</programlisting>
|
|||
|
|
</example>
|
|||
|
|
</sect2>
|
|||
|
|
<sect2 id="section.property.show">
|
|||
|
|
<title>show</title>
|
|||
|
|
<para>
|
|||
|
|
<emphasis>show</emphasis> <20> usado como par<61>metro para section.
|
|||
|
|
<emphasis>show</emphasis> <20> um valor booleano, true ou false. Se
|
|||
|
|
false, a section n<>o ser<65> mostrada. Se existir um sectionelse
|
|||
|
|
presente, esta ser<65> alternativamente mostrado.
|
|||
|
|
</para>
|
|||
|
|
<example>
|
|||
|
|
<title>section attribute show</title>
|
|||
|
|
<programlisting>
|
|||
|
|
{* $show_customer_info deve ser passada da aplica<63><61>o PHP,
|
|||
|
|
para regular quando mostrar ou n<>o mostrar esta section *}
|
|||
|
|
{section name=customer loop=$custid show=$show_customer_info}
|
|||
|
|
{$smarty.section.customer.rownum} id: {$custid[customer]}<br>
|
|||
|
|
{/section}
|
|||
|
|
|
|||
|
|
{if $smarty.section.customer.show}
|
|||
|
|
the section was shown.
|
|||
|
|
{else}
|
|||
|
|
the section was not shown.
|
|||
|
|
{/if}
|
|||
|
|
|
|||
|
|
|
|||
|
|
MOSTRA:
|
|||
|
|
|
|||
|
|
1 id: 1000<br>
|
|||
|
|
2 id: 1001<br>
|
|||
|
|
3 id: 1002<br>
|
|||
|
|
|
|||
|
|
the section was shown.
|
|||
|
|
</programlisting>
|
|||
|
|
</example>
|
|||
|
|
</sect2>
|
|||
|
|
<sect2 id="section.property.total">
|
|||
|
|
<title>total</title>
|
|||
|
|
<para>
|
|||
|
|
total <20> usado para mostrar o n<>mero de intera<72><61>es que esta section ter<65>.
|
|||
|
|
Isto pode ser usado dentro ou depois da section.
|
|||
|
|
</para>
|
|||
|
|
<example>
|
|||
|
|
<title>section property total</title>
|
|||
|
|
<programlisting>
|
|||
|
|
{section name=customer loop=$custid step=2}
|
|||
|
|
{$smarty.section.customer.index} id: {$custid[customer]}<br>
|
|||
|
|
{/section}
|
|||
|
|
|
|||
|
|
There were {$smarty.section.customer.total} customers shown above.
|
|||
|
|
|
|||
|
|
MOSTRA:
|
|||
|
|
|
|||
|
|
0 id: 1000<br>
|
|||
|
|
2 id: 1001<br>
|
|||
|
|
4 id: 1002<br>
|
|||
|
|
|
|||
|
|
There were 3 customers shown above.
|
|||
|
|
</programlisting>
|
|||
|
|
</example>
|
|||
|
|
</sect2>
|
|||
|
|
</sect1>
|
|||
|
|
<!-- Keep this comment at the end of the file
|
|||
|
|
Local variables:
|
|||
|
|
mode: sgml
|
|||
|
|
sgml-omittag:t
|
|||
|
|
sgml-shorttag:t
|
|||
|
|
sgml-minimize-attributes:nil
|
|||
|
|
sgml-always-quote-attributes:t
|
|||
|
|
sgml-indent-step:1
|
|||
|
|
sgml-indent-data:t
|
|||
|
|
indent-tabs-mode:nil
|
|||
|
|
sgml-parent-document:nil
|
|||
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|||
|
|
sgml-exposed-tags:nil
|
|||
|
|
sgml-local-catalogs:nil
|
|||
|
|
sgml-local-ecat-files:nil
|
|||
|
|
End:
|
|||
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|||
|
|
vim: et tw=78 syn=sgml
|
|||
|
|
vi: ts=1 sw=1
|
|||
|
|
-->
|