mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-01 04:41:37 +01:00
added italian docs. thanks to Gianluca Gillini
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.capture">
|
||||
<title>capture</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 Attributo</entry>
|
||||
<entry>Tipo</entry>
|
||||
<entry>Obbligatorio</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Descrizione</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>name</entry>
|
||||
<entry>stringa</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>default</emphasis></entry>
|
||||
<entry>Nome del blocco catturato</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>assign</entry>
|
||||
<entry>stringa</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>nessuno</emphasis></entry>
|
||||
<entry>Nome della variabile cui assegnare l'output catturato</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
capture si usa per intercettare l'output del template assegnandolo
|
||||
ad una variabile invece di visualizzarlo. Qualsiasi contenuto compreso
|
||||
fra {capture name="foo"} e {/capture} viene aggiunto alla variabile
|
||||
specificata nell'attributo name. Il contenuto catturato pu<70> essere
|
||||
usato nel template utilizzando la variabile speciale $smarty.capture.foo
|
||||
dove foo <20> il nome passato nell'attributo name. Se non fornite un
|
||||
attributo name, verr<72> usato "default". Tutti i comandi {capture}
|
||||
devono essere chiusi con {/capture}. E' possibile nidificarli.
|
||||
</para>
|
||||
<note>
|
||||
<title>Nota tecnica</title>
|
||||
<para>
|
||||
Le versioni da 1.4.0 a 1.4.4 di Smarty mettevano il contenuto catturato
|
||||
nella variabile $return. A partire dalla 1.4.5 si utilizza l'attributo
|
||||
name, quindi modificate i vostri template di conseguenza.
|
||||
</para>
|
||||
</note>
|
||||
<caution>
|
||||
<para>
|
||||
Fate attenzione se catturate l'output di <command>insert</command>.
|
||||
Se avete il caching attivato e usate comandi <command>insert</command>
|
||||
che vi aspettate vengano eseguiti nel contenuto in cache, non
|
||||
catturate questo contenuto.
|
||||
</para>
|
||||
</caution>
|
||||
<para>
|
||||
<example>
|
||||
<title>catturare il contenuto del template</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* vogliamo stampare la riga di tabella solo se c'<27> del contenuto *}
|
||||
{capture name=banner}
|
||||
{include file="get_banner.tpl"}
|
||||
{/capture}
|
||||
{if $smarty.capture.banner ne ""}
|
||||
<tr>
|
||||
<td>
|
||||
{$smarty.capture.banner}
|
||||
</td>
|
||||
</tr>
|
||||
{/if}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
</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
|
||||
-->
|
||||
@@ -0,0 +1,148 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.config.load">
|
||||
<title>config_load</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 Attributo</entry>
|
||||
<entry>Tipo</entry>
|
||||
<entry>Obbligatorio</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Descrizione</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>file</entry>
|
||||
<entry>stringa</entry>
|
||||
<entry>s<EFBFBD></entry>
|
||||
<entry><emphasis>nessuno</emphasis></entry>
|
||||
<entry>Nome del file di configurazione da importare</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>section</entry>
|
||||
<entry>stringa</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>nessuno</emphasis></entry>
|
||||
<entry>Nome della sezione da caricare</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>scope</entry>
|
||||
<entry>stringa</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>local</emphasis></entry>
|
||||
<entry>
|
||||
Campo di applicazione delle variabili caricate,
|
||||
che pu<70> essere local, parent o global. local significa
|
||||
che le variabili vengono caricate nel contesto del
|
||||
template locale. parent significa che le variabili
|
||||
vengono caricate sia nel contesto locale che nel template
|
||||
genitore che lo ha chiamato. global significa che le
|
||||
variabili sono disponibili a tutti i template.
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>global</entry>
|
||||
<entry>booleano</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>false</emphasis></entry>
|
||||
<entry>
|
||||
Se le variabili sono visibili o meno al template
|
||||
genitore: equivale a scope=parent. NOTA: Questo attributo
|
||||
<20> deprecato per via dell'esistenza dell'attributo scope,
|
||||
ma <20> ancora supportato. Se <20> presente scope, questo valore
|
||||
<20> ignorato.
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
Questa funzione <20> usata per caricare variabili nel template da
|
||||
un file di configurazione.
|
||||
Vedere <link linkend="config.files">Config Files</link> per
|
||||
maggiori informazioni.
|
||||
</para>
|
||||
<example>
|
||||
<title>funzione config_load</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{config_load file="colors.conf"}
|
||||
|
||||
<html>
|
||||
<title>{#pageTitle#}</title>
|
||||
<body bgcolor="{#bodyBgColor#}">
|
||||
<table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}">
|
||||
<tr bgcolor="{#rowBgColor#}">
|
||||
<td>First</td>
|
||||
<td>Last</td>
|
||||
<td>Address</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
I file di configurazione possono contenere sezioni. Potete caricare
|
||||
variabili da una sezione con l'attributo aggiuntivo
|
||||
<emphasis>section</emphasis>.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
<emphasis>Le sezioni dei file di configurazione</emphasis> e la funzione
|
||||
incorporata dei template chiamata <emphasis>section</emphasis> non hanno
|
||||
nulla a che fare fra di loro, hanno soltanto lo stesso nome.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>funzione config_load con section</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{config_load file="colors.conf" section="Customer"}
|
||||
|
||||
<html>
|
||||
<title>{#pageTitle#}</title>
|
||||
<body bgcolor="{#bodyBgColor#}">
|
||||
<table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}">
|
||||
<tr bgcolor="{#rowBgColor#}">
|
||||
<td>First</td>
|
||||
<td>Last</td>
|
||||
<td>Address</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</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
|
||||
-->
|
||||
@@ -0,0 +1,191 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.foreach">
|
||||
<title>foreach,foreachelse</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 Attributo</entry>
|
||||
<entry>Tipo</entry>
|
||||
<entry>Obbligatorio</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Descrizione</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>from</entry>
|
||||
<entry>array</entry>
|
||||
<entry>s<EFBFBD></entry>
|
||||
<entry><emphasis>nessuno</emphasis></entry>
|
||||
<entry>Array sul quale viene eseguito il ciclo</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>item</entry>
|
||||
<entry>stringa</entry>
|
||||
<entry>s<EFBFBD></entry>
|
||||
<entry><emphasis>nessuno</emphasis></entry>
|
||||
<entry>Nome della variabile che rappresenta
|
||||
l'elemento attuale</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>key</entry>
|
||||
<entry>stringa</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>nessuno</emphasis></entry>
|
||||
<entry>Nome della variabile che rappresenta la chiave attuale</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>name</entry>
|
||||
<entry>stringa</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>nessuno</emphasis></entry>
|
||||
<entry>Nome del ciclo foreach per l'accesso alle sue propriet<65></entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
I cicli <emphasis>foreach</emphasis> sono un'alternativa ai cicli
|
||||
<emphasis>section</emphasis>. <emphasis>foreach</emphasis> si usa
|
||||
per ciclare su un singolo array associativo. La sintassi di
|
||||
<emphasis>foreach</emphasis> <20> molto pi<70> semplice di
|
||||
<emphasis>session</emphasis>, ma in compenso pu<70> essere usata solo
|
||||
per un array singolo. I tag <emphasis>foreach</emphasis> devono
|
||||
essere chiusi con <emphasis>/foreach</emphasis>. I parametri
|
||||
obbligatori sono <emphasis>from</emphasis> e <emphasis>item</emphasis>.
|
||||
Il nome del ciclo foreach pu<70> essere quello che preferite, composto
|
||||
di lettere, numeri e underscore. I cicli <emphasis>foreach</emphasis>
|
||||
possono essere nidificati, ma i nomi dei cicli nidificati devono
|
||||
essere diversi tra di loro. La variabile <emphasis>from</emphasis>
|
||||
(di solito un array di valori) determina quante volte verr<72> eseguito
|
||||
il ciclo <emphasis>foreach</emphasis>.
|
||||
<emphasis>foreachelse</emphasis> viene eseguito quando non ci sono
|
||||
valori nella variabile <emphasis>from</emphasis>.
|
||||
</para>
|
||||
<example>
|
||||
<title>foreach</title>
|
||||
<programlisting>
|
||||
|
||||
{* questo esempio stamper<65> tutti i valori dell'array $custid *}
|
||||
{foreach from=$custid item=curr_id}
|
||||
id: {$curr_id}<br>
|
||||
{/foreach}
|
||||
|
||||
OUTPUT:
|
||||
|
||||
id: 1000<br>
|
||||
id: 1001<br>
|
||||
id: 1002<br></programlisting>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>foreach con key</title>
|
||||
<programlisting>
|
||||
{* key contiene la chiave per ogni valore del ciclo
|
||||
|
||||
l'assegnazione pu<70> essere qualcosa del genere:
|
||||
|
||||
$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
|
||||
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
|
||||
|
||||
*}
|
||||
|
||||
{foreach name=outer item=contact from=$contacts}
|
||||
{foreach key=key item=item from=$contact}
|
||||
{$key}: {$item}<br>
|
||||
{/foreach}
|
||||
{/foreach}
|
||||
|
||||
OUTPUT:
|
||||
|
||||
phone: 1<br>
|
||||
fax: 2<br>
|
||||
cell: 3<br>
|
||||
phone: 555-4444<br>
|
||||
fax: 555-3333<br>
|
||||
cell: 760-1234<br></programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
I cicli foreach hanno anche le proprie variabili che gestiscono le propriet<65>
|
||||
del foreach. Queste vengono indicate cos<6F>: {$smarty.foreach.foreachname.varname},
|
||||
dove foreachname <20> il nome indicato come attributo <emphasis>name</emphasis>
|
||||
del foreach
|
||||
</para>
|
||||
|
||||
|
||||
<sect2 id="foreach.property.iteration">
|
||||
<title>iteration</title>
|
||||
<para>
|
||||
iteration si usa per mostrare l'iterazione corrente del ciclo.
|
||||
</para>
|
||||
<para>
|
||||
iteration comincia sempre per 1 ed <20> incrementata di uno
|
||||
ad ogni iterazione.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="foreach.property.first">
|
||||
<title>first</title>
|
||||
<para>
|
||||
<emphasis>first</emphasis> vale true quando l'iterazione attuale <20> la prima del ciclo.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="foreach.property.last">
|
||||
<title>last</title>
|
||||
<para>
|
||||
<emphasis>last</emphasis> vale true quando l'iterazione attuale <20> l'ultima del ciclo.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="foreach.property.show">
|
||||
<title>show</title>
|
||||
<para>
|
||||
<emphasis>show</emphasis> si usa come parametro per il foreach.
|
||||
<emphasis>show</emphasis> <20> un valore booleano, true o false. Quando
|
||||
<09> false, il foreach non verr<72> visualizzato. Se <20> presente un
|
||||
foreachelse, verr<72> visualizzato al suo posto.
|
||||
</para>
|
||||
|
||||
</sect2>
|
||||
<sect2 id="foreach.property.total">
|
||||
<title>total</title>
|
||||
<para>
|
||||
<emphasis>total</emphasis> si usa per visualizzare il numero di iterazioni che il
|
||||
ciclo foreach effettuer<65>. Pu<50> essere usato all'interno o dopo il foreach.
|
||||
</para>
|
||||
</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
|
||||
-->
|
||||
@@ -0,0 +1,219 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.if">
|
||||
<title>if,elseif,else</title>
|
||||
<para>
|
||||
Le istruzioni <emphasis>{if}</emphasis> in Smarty hanno praticamente la
|
||||
stessa flessibilit<69> delle istruzioni if PHP, con qualche caratteristica
|
||||
aggiuntiva per il motore di template.
|
||||
Ogni <emphasis>{if}</emphasis> deve essere chiuso con un
|
||||
<emphasis>{/if}</emphasis>. Sono previsti anche <emphasis>{else}</emphasis>
|
||||
e <emphasis>{elseif}</emphasis>. Sono riconosciuti tutti gli operatori condizionali
|
||||
di PHP, come <emphasis>||</emphasis>, <emphasis>or</emphasis>,
|
||||
<emphasis>&&</emphasis>, <emphasis>and</emphasis>, ecc.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Quella che segue <20> una lista degli operatori riconosciuti, che devono
|
||||
essere separati con degli spazi dagli elementi circostanti. Notate che
|
||||
gli elementi mostrati fra [parentesi quadre] sono opzionali. Quando esistono
|
||||
sono mostrati gli equivalenti in PHP.
|
||||
</para>
|
||||
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="4">
|
||||
<colspec colname="qualifier" align="center" />
|
||||
<colspec colname="alternates" align="center" />
|
||||
<colspec colname="meaning" />
|
||||
<colspec colname="example" />
|
||||
<colspec colname="php" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Operatore</entry>
|
||||
<entry>Alternative</entry>
|
||||
<entry>Esempio di sintassi</entry>
|
||||
<entry>Significato</entry>
|
||||
<entry>Equivalente PHP</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>==</entry>
|
||||
<entry>eq</entry>
|
||||
<entry>$a eq $b</entry>
|
||||
<entry>uguale</entry>
|
||||
<entry>==</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>!=</entry>
|
||||
<entry>ne, neq</entry>
|
||||
<entry>$a neq $b</entry>
|
||||
<entry>diverso</entry>
|
||||
<entry>!=</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>></entry>
|
||||
<entry>gt</entry>
|
||||
<entry>$a gt $b</entry>
|
||||
<entry>maggiore di</entry>
|
||||
<entry>></entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><</entry>
|
||||
<entry>lt</entry>
|
||||
<entry>$a lt $b</entry>
|
||||
<entry>minore di</entry>
|
||||
<entry><</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>>=</entry>
|
||||
<entry>gte, ge</entry>
|
||||
<entry>$a ge $b</entry>
|
||||
<entry>maggiore o uguale</entry>
|
||||
<entry>>=</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry><=</entry>
|
||||
<entry>lte, le</entry>
|
||||
<entry>$a le $b</entry>
|
||||
<entry>minore o uguale</entry>
|
||||
<entry><=</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>!</entry>
|
||||
<entry>not</entry>
|
||||
<entry>not $a</entry>
|
||||
<entry>negazione (unario)</entry>
|
||||
<entry>!</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>%</entry>
|
||||
<entry>mod</entry>
|
||||
<entry>$a mod $b</entry>
|
||||
<entry>modulo (resto della divisione)</entry>
|
||||
<entry>%</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>is [not] div by</entry>
|
||||
<entry></entry>
|
||||
<entry>$a is not div by 4</entry>
|
||||
<entry>divisibile per</entry>
|
||||
<entry>$a % $b == 0</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>is [not] even</entry>
|
||||
<entry></entry>
|
||||
<entry>$a is not even</entry>
|
||||
<entry>[non] <20> un numero pari (unario)</entry>
|
||||
<entry>$a % 2 == 0</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>is [not] even by</entry>
|
||||
<entry></entry>
|
||||
<entry>$a is not even by $b</entry>
|
||||
<entry>livello di raggruppamento [non] pari</entry>
|
||||
<entry>($a / $b) % 2 == 0</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>is [not] odd</entry>
|
||||
<entry></entry>
|
||||
<entry>$a is not odd</entry>
|
||||
<entry>[non] <20> un numero dispari (unario)</entry>
|
||||
<entry>$a % 2 != 0</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>is [not] odd by</entry>
|
||||
<entry></entry>
|
||||
<entry>$a is not odd by $b</entry>
|
||||
<entry>livello di raggruppamento [non] dispari</entry>
|
||||
<entry>($a / $b) % 2 != 0</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<example>
|
||||
<title>Istruzioni if</title>
|
||||
<programlisting>
|
||||
{if $name eq "Fred"}
|
||||
Welcome Sir.
|
||||
{elseif $name eq "Wilma"}
|
||||
Welcome Ma'am.
|
||||
{else}
|
||||
Welcome, whatever you are.
|
||||
{/if}
|
||||
|
||||
{* un esempio con "or" logico *}
|
||||
{if $name eq "Fred" or $name eq "Wilma"}
|
||||
...
|
||||
{/if}
|
||||
|
||||
{* come sopra *}
|
||||
{if $name == "Fred" || $name == "Wilma"}
|
||||
...
|
||||
{/if}
|
||||
|
||||
{* questa sintassi NON funziona, gli operatori condizionali
|
||||
devono essere separati con spazi dagli elementi circostanti *}
|
||||
{if $name=="Fred" || $name=="Wilma"}
|
||||
...
|
||||
{/if}
|
||||
|
||||
|
||||
{* si possono usare le parentesi *}
|
||||
{if ( $amount < 0 or $amount > 1000 ) and $volume >= #minVolAmt#}
|
||||
...
|
||||
{/if}
|
||||
|
||||
{* potete anche incorporare chiamate a funzioni php *}
|
||||
{if count($var) gt 0}
|
||||
...
|
||||
{/if}
|
||||
|
||||
{* test su valori pari o dispari *}
|
||||
{if $var is even}
|
||||
...
|
||||
{/if}
|
||||
{if $var is odd}
|
||||
...
|
||||
{/if}
|
||||
{if $var is not odd}
|
||||
...
|
||||
{/if}
|
||||
|
||||
{* test se var <20> divisibile per 4 *}
|
||||
{if $var is div by 4}
|
||||
...
|
||||
{/if}
|
||||
|
||||
{* test se var <20> pari, raggruppato per due. Ad es.:
|
||||
0=pari, 1=pari, 2=dispari, 3=dispari, 4=pari, 5=pari, etc. *}
|
||||
{if $var is even by 2}
|
||||
...
|
||||
{/if}
|
||||
|
||||
{* 0=pari, 1=pari, 2=pari, 3=dispari, 4=dispari, 5=dispari, etc. *}
|
||||
{if $var is even by 3}
|
||||
...
|
||||
{/if}</programlisting>
|
||||
</example>
|
||||
</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
|
||||
-->
|
||||
@@ -0,0 +1,140 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.include.php">
|
||||
<title>include_php</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 Attributo</entry>
|
||||
<entry>Tipo</entry>
|
||||
<entry>Obbligatorio</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Descrizione</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>file</entry>
|
||||
<entry>stringa</entry>
|
||||
<entry>s<EFBFBD></entry>
|
||||
<entry><emphasis>nessuno</emphasis></entry>
|
||||
<entry>Nome del file php da includere</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>once</entry>
|
||||
<entry>booleano</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>true</emphasis></entry>
|
||||
<entry>Se includere o no il file php pi<70> di una volta nel
|
||||
caso venga richiesto pi<70> volte</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>assign</entry>
|
||||
<entry>stringa</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>nessuno</emphasis></entry>
|
||||
<entry>Nome della variabile cui sar<61> assegnato l'output
|
||||
di include_php</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<note>
|
||||
<title>Nota Tecnica</title>
|
||||
<para>
|
||||
include_php <20> deprecato da Smarty, in quanto potete ottenere la
|
||||
stessa funzionalit<69> attraverso una funzione utente.
|
||||
L'unica ragione per usare include_php <20> se avete una reale
|
||||
necessit<69> di tenere fuori la funzione php dalla directory dei plugin
|
||||
o dal vostro codice applicativo. Vedere l'<link
|
||||
linkend="tips.componentized.templates">esempio di template a
|
||||
componenti</link> per i dettagli.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
i tag include_php sono usati per includere uno script php nel
|
||||
template. Se la security <20> abilitata, lo script php si deve
|
||||
trovare nel percorso di $trusted_dir. Il tag include_php deve
|
||||
avere l'attributo "file", che contiene il percorso al file da
|
||||
includere, che pu<70> essere assoluto relativo alla directory $trusted_dir.
|
||||
</para>
|
||||
<para>
|
||||
include_php <20> un ottimo modo per gestire template a componenti, e
|
||||
tiene il codice PHP separato dai file dei template. Diciamo che abbiamo
|
||||
un template che mostra la navigazione del nostro sito, che viene
|
||||
prelevata dinamicamente da un database. Possiamo tenere la logica PHP
|
||||
che ottiene il contenuto del database in una directory separata, ed
|
||||
includerla in cima al template. Ora possiamo includere questo
|
||||
template ovunque senza preoccuparci che l'applicazione abbia
|
||||
preventivamente caricato i dati del database.
|
||||
</para>
|
||||
<para>
|
||||
Per default, i file php sono inclusi una sola volta, anche se richiesti
|
||||
pi<70> volte nel template. Potete specificare che devono essere inclusi
|
||||
ogni volta con l'attributo <emphasis>once</emphasis>. Se impostate
|
||||
once a false, lo script verr<72> incluso tutte le volte che viene
|
||||
richiesto nel template.
|
||||
</para>
|
||||
<para>
|
||||
Opzionalmente potete passare l'attributo <emphasis>assign</emphasis>,
|
||||
che specifica un nome di variabile cui sar<61> assegnato l'output di
|
||||
<emphasis>include_php</emphasis>, invece di essere visualizzato.
|
||||
</para>
|
||||
<para>
|
||||
L'oggetto smarty <20> disponibile come $this all'interno dello script
|
||||
PHP che viene incluso.
|
||||
</para>
|
||||
<example>
|
||||
<title>funzione include_php</title>
|
||||
<programlisting>
|
||||
load_nav.php
|
||||
-------------
|
||||
|
||||
<?php
|
||||
|
||||
// carichiamo le variabili da un db mysql e le assegnamo al template
|
||||
require_once("MySQL.class.php");
|
||||
$sql = new MySQL;
|
||||
$sql->query("select * from site_nav_sections order by name",SQL_ALL);
|
||||
$this->assign('sections',$sql->record);
|
||||
|
||||
?>
|
||||
|
||||
|
||||
index.tpl
|
||||
---------
|
||||
|
||||
{* percorso assoluto, o relativo a $trusted_dir *}
|
||||
{include_php file="/path/to/load_nav.php"}
|
||||
|
||||
{foreach item="curr_section" from=$sections}
|
||||
<a href="{$curr_section.url}">{$curr_section.name}</a><br>
|
||||
{/foreach}</programlisting>
|
||||
</example>
|
||||
</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
|
||||
-->
|
||||
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.include">
|
||||
<title>include</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 Attributo</entry>
|
||||
<entry>Tipo</entry>
|
||||
<entry>Obbligatorio</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Descrizione</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>file</entry>
|
||||
<entry>stringa</entry>
|
||||
<entry>s<EFBFBD></entry>
|
||||
<entry><emphasis>nessuno</emphasis></entry>
|
||||
<entry>Nome del file di template da includere</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>assign</entry>
|
||||
<entry>stringa</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>nessuno</emphasis></entry>
|
||||
<entry>Nome della variabile cui sar<61> assegnato
|
||||
l'output dell'include</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>[variabile ...]</entry>
|
||||
<entry>[tipo variabile]</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>nessuno</emphasis></entry>
|
||||
<entry>Variabile da passare localmente al template</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
I tag include sono usati per includere altri template in quello attuale.
|
||||
Tutte le variabili del template corrente sono disponibili anche nel
|
||||
template incluso. Il tag include deve comprendere l'attributo "file",
|
||||
che contiene il percorso del template da includere.
|
||||
</para>
|
||||
<para>
|
||||
Opzionalmente si pu<70> passare l'attributo <emphasis>assign</emphasis>,
|
||||
che specifica un nome di variabile del template alla quale
|
||||
sar<61> assegnato l'output dell'<emphasis>include</emphasis>, invece
|
||||
di essere visualizzato.
|
||||
</para>
|
||||
<example>
|
||||
<title>funzione include</title>
|
||||
<programlisting>
|
||||
{include file="header.tpl"}
|
||||
|
||||
{* qui va il corpo del template *}
|
||||
|
||||
{include file="footer.tpl"}</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Potete anche passare variabili ai template inclusi sotto forma di
|
||||
attributi. Queste variabili saranno disponibili soltanto nello
|
||||
scope del file incluso. Le variabili attributo prevalgono su quelle
|
||||
del template attuale in caso di omonimia.
|
||||
</para>
|
||||
<example>
|
||||
<title>funzione include con passaggio di variabili</title>
|
||||
<programlisting>
|
||||
{include file="header.tpl" title="Main Menu" table_bgcolor="#c0c0c0"}
|
||||
|
||||
{* qui va il corpo del template *}
|
||||
|
||||
{include file="footer.tpl" logo="http://my.example.com/logo.gif"}</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Usate la sintassi delle <link
|
||||
linkend="template.resources">risorse dei template</link> per
|
||||
includere file esterni alla directory $template_dir.
|
||||
</para>
|
||||
<example>
|
||||
<title>esempi di funzione include con le risorse dei template</title>
|
||||
<programlisting>
|
||||
{* percorso assoluto *}
|
||||
{include file="/usr/local/include/templates/header.tpl"}
|
||||
|
||||
{* percorso assoluto (come sopra) *}
|
||||
{include file="file:/usr/local/include/templates/header.tpl"}
|
||||
|
||||
{* percorso assoluto su windows (NECESSARIO usare il prefisso "file:") *}
|
||||
{include file="file:C:/www/pub/templates/header.tpl"}
|
||||
|
||||
{* include da una risorsa chiamata "db" *}
|
||||
{include file="db:header.tpl"}</programlisting>
|
||||
</example>
|
||||
</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
|
||||
-->
|
||||
@@ -0,0 +1,144 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.insert">
|
||||
<title>insert</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 Attributo</entry>
|
||||
<entry>Tipo</entry>
|
||||
<entry>Obbligatorio</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Descrizione</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>name</entry>
|
||||
<entry>stringa</entry>
|
||||
<entry>s<EFBFBD></entry>
|
||||
<entry><emphasis>nessuno</emphasis></entry>
|
||||
<entry>Nome della funzione di insert (insert_name)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>assign</entry>
|
||||
<entry>stringa</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>nessuno</emphasis></entry>
|
||||
<entry>Nome della variabile del template cui verr<72>
|
||||
assegnato l'output</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>script</entry>
|
||||
<entry>stringa</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>nessuno</emphasis></entry>
|
||||
<entry>Nome dello script php che viene incluso prima
|
||||
della chiamata alla funzione di insert</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>[variabile ...]</entry>
|
||||
<entry>[tipo variabile]</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>nessuno</emphasis></entry>
|
||||
<entry>Variabile da passare alla funzione di insert</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
I tag insert funzionano praticamente come i tag include, ad
|
||||
eccezione del fatto che i tag insert non vengono messi in
|
||||
cache quando avete il <link linkend="caching">caching</link>
|
||||
del template abilitato. Verranno quindi eseguiti ad ogni
|
||||
chiamata del template.
|
||||
</para>
|
||||
<para>
|
||||
Diciamo che abbiamo un template con uno spazio banner in cima
|
||||
alla pagina. Il banner pu<70> contenere qualsiasi mescolanza di HTML,
|
||||
immagini, flash, ecc., quindi non possiamo usare un link statico,
|
||||
e non vogliamo che questo contenuto sia messo in cache con la
|
||||
pagina. Ecco quindi l'utilit<69> del tag insert: il template conosce i
|
||||
valori di #banner_location_id# e #site_id# (presi da un file di
|
||||
configurazione), e ha bisogno di chiamare una funzione per ottenere
|
||||
il contenuto del banner.
|
||||
</para>
|
||||
<example>
|
||||
<title>funzione insert</title>
|
||||
<programlisting>
|
||||
{* esempio di caricamento di un banner *}
|
||||
{insert name="getBanner" lid=#banner_location_id# sid=#site_id#}</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
In questo esempio stiamo usando il nome "getBanner" e passiamo i
|
||||
parametri #banner_location_id# e #site_id#. Smarty cercher<65> una
|
||||
funzione chiamata insert_getBanner() nell'applicazione PHP, passandole
|
||||
i valori di #banner_location_id# e #site_id# come primo argomento
|
||||
in un array associativo. Tutti i nomi di funzioni di insert
|
||||
nell'applicazione devono essere prefissati con "insert_", per evitare
|
||||
possibili conflitti nei nomi di funzione. La nostra funzione
|
||||
insert_getBanner() far<61> qualcosa con i valori passati e restituir<69>
|
||||
il risultato, che verr<72> visualizzato nel templat al posto del tag
|
||||
insert.
|
||||
In questo esempio, Smarty chiamerebbe questa funzione:
|
||||
insert_getBanner(array("lid" => "12345","sid" => "67890"));
|
||||
e visualizzerebbe il risultato restituito al posto del tag insert.
|
||||
</para>
|
||||
<para>
|
||||
Se fornite l'attributo "assign", l'output del tag insert verr<72>
|
||||
assegnato a questa variabile invece di essere mostrato nel template.
|
||||
NOTA: assegnare l'output ad una variabile non <20> molto utile se il
|
||||
caching <20> abilitato.
|
||||
</para>
|
||||
<para>
|
||||
Se fornite l'attributo "script", questo script verr<72> incluso (una
|
||||
volta sola) prima dell'esecuzione della funzione di insert. Questo
|
||||
caso pu<70> presentarsi quando la funzione di insert pu<70> non esistere
|
||||
ancora, e uno script php deve essere quindi incluso per farla
|
||||
funzionare. Il percorso pu<70> essere assoluto o relativo a $trusted_dir.
|
||||
Se la security <20> abilitata, lo script deve trovarsi in $trusted_dir.
|
||||
</para>
|
||||
<para>
|
||||
Come secondo argomento viene passato l'oggetto Smarty. In questo
|
||||
modo potete ottenere e modificare informazioni nell'oggetto Smarty
|
||||
dall'interno della funzione di insert.
|
||||
</para>
|
||||
<note>
|
||||
<title>Nota tecnica</title>
|
||||
<para>
|
||||
E' possibile avere porzioni di template non in cache. Se
|
||||
avete il <link linkend="caching">caching</link> abilitato,
|
||||
i tag insert non verranno messi in cache. Verranno quindi
|
||||
eseguiti dinamicamente ogni volta che la pagina viene creata,
|
||||
anche se questa si trova in cache. Questo viene utile per cose
|
||||
come banner, sondaggi, situazione del tempo, risultati di ricerche,
|
||||
aree di feedback utenti, ecc.
|
||||
</para>
|
||||
</note>
|
||||
</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
|
||||
-->
|
||||
@@ -0,0 +1,52 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.ldelim">
|
||||
<title>ldelim,rdelim</title>
|
||||
<para>
|
||||
ldelim e rdelim si usano per fare l'escape dei delimitatori del template, nel nostro caso
|
||||
"{" o "}". Potete usare anche <link
|
||||
linkend="language.function.literal">{literal}{/literal}</link> per fare l'escape su
|
||||
blocchi di testo.
|
||||
Vedere anche <link linkend="language.variables.smarty.ldelim">{$smarty.ldelim}</link>
|
||||
e <link linkend="language.variables.smarty.rdelim">{$smarty.rdelim}</link>
|
||||
</para>
|
||||
<example>
|
||||
<title>ldelim, rdelim</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* questo stamper<65> i delimitatori *}
|
||||
|
||||
{ldelim}funcname{rdelim} is how functions look in Smarty!
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
L'esempio sopra produrr<72>:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
{funcname} is how functions look in Smarty!
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</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
|
||||
-->
|
||||
@@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.literal">
|
||||
<title>literal</title>
|
||||
<para>
|
||||
I tag literal vi consentono di far s<> che un blocco di dati venga letto
|
||||
"letteralmente". Ci<43> <20> utile tipicamente quando avete un blocco javascript
|
||||
o CSS nel quale le parentesi graffe si confonderebbero con i delimitatori
|
||||
del template. Tutto ci<63> che si trova fra {literal} e {/literal} non viene
|
||||
interpretato, ma visualizzato cos<6F> com'<27>. Se avete bisogno di usare tag
|
||||
del template all'interno del blocco literal, considerate la possibilit<69> di
|
||||
usare invece <link linkend="language.function.ldelim">{ldelim}{rdelim}</link>
|
||||
per fare l'escape dei singoli delimitatori.
|
||||
</para>
|
||||
<example>
|
||||
<title>tag literal</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{literal}
|
||||
<script type="text/javascript">
|
||||
|
||||
<!--
|
||||
function isblank(field) {
|
||||
if (field.value == '')
|
||||
{ return false; }
|
||||
else
|
||||
{
|
||||
document.loginform.submit();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// -->
|
||||
|
||||
</script>
|
||||
{/literal}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</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
|
||||
-->
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.php">
|
||||
<title>php</title>
|
||||
<para>
|
||||
I tag php vi consentono di incorporare codice php direttamente
|
||||
nel template. Non sar<61> fatto l'escape, indipendentemente
|
||||
dall'impostazione di <link
|
||||
linkend="variable.php.handling">$php_handling</link>.
|
||||
Questa funzione <20> solo per utenti avanzati, normalmente non
|
||||
dovreste averne bisogno.
|
||||
</para>
|
||||
<example>
|
||||
<title>tag php</title>
|
||||
<programlisting>
|
||||
{php}
|
||||
// inclusione di uno script php
|
||||
// direttamente dal template.
|
||||
include("/path/to/display_weather.php");
|
||||
{/php}</programlisting>
|
||||
</example>
|
||||
</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
|
||||
-->
|
||||
@@ -0,0 +1,569 @@
|
||||
<?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 Attributo</entry>
|
||||
<entry>Tipo</entry>
|
||||
<entry>Obbligatorio</entry>
|
||||
<entry>Default</entry>
|
||||
<entry>Descrizione</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
<row>
|
||||
<entry>name</entry>
|
||||
<entry>stringa</entry>
|
||||
<entry>s<EFBFBD></entry>
|
||||
<entry><emphasis>nessuno</emphasis></entry>
|
||||
<entry>Nome della sezione</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>loop</entry>
|
||||
<entry>[$variable_name]</entry>
|
||||
<entry>s<EFBFBD></entry>
|
||||
<entry><emphasis>nessuno</emphasis></entry>
|
||||
<entry>Nome della variabile che determina il numero
|
||||
di iterazioni del ciclo</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>start</entry>
|
||||
<entry>intero</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>0</emphasis></entry> <entry>L'indice
|
||||
dal quale inizier<65> il ciclo. Se il valore <20> negativo,
|
||||
la posizione di partenza <20> calcolata dalla fine dell'array.
|
||||
Ad esempio, se ci sono sette valori nell'array da ciclare
|
||||
e start <20> -2, l'indice di partenza sar<61> 5. Valori non
|
||||
validi (cio<69> al di fuori della lunghezza dell'array da
|
||||
ciclare) saranno automaticamente convertiti al valore
|
||||
valido pi<70> vicino.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>step</entry>
|
||||
<entry>intero</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>1</emphasis></entry>
|
||||
<entry>Il valore di passo da usare per attraversare
|
||||
l'array da ciclare. Ad esempio, step=2 cicler<65> sugli
|
||||
indici 0,2,4, ecc. Se step <20> negativo il ciclo proceder<65>
|
||||
sull'array all'indietro.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>max</entry>
|
||||
<entry>intero</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>nessuno</emphasis></entry>
|
||||
<entry>Massimo numero di cicli per la sezione.</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>show</entry>
|
||||
<entry>booleano</entry>
|
||||
<entry>no</entry>
|
||||
<entry><emphasis>true</emphasis></entry>
|
||||
<entry>Stabilisce se mostrare o no la sezione</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
Le sezioni sono usate per ciclare su array di dati. Tutti i tag
|
||||
<emphasis>section</emphasis> devono essere chiusi con
|
||||
<emphasis>/section</emphasis>. I parametri obbligatori sono
|
||||
<emphasis>name</emphasis> e <emphasis>loop</emphasis>. Il nome
|
||||
della sezione pu<70> essere quello che preferite, formato da lettere,
|
||||
numeri e underscore. Le sezioni possono essere nidificate, ed i nomi
|
||||
delle sezioni nidificate devono essere diversi fra loro. La variabile
|
||||
loop (di solito un array di valori) determina quante volte sar<61>
|
||||
eseguito il ciclo. Quando stampate una variabile all'interno di una
|
||||
sezione, il nome della sezione deve essere indicato a fianco del
|
||||
nome della variabile fra parentesi quadre [].
|
||||
<emphasis>sectionelse</emphasis> viene eseguito quando non ci sono
|
||||
valori nella variabile loop.
|
||||
</para>
|
||||
<example>
|
||||
<title>section</title>
|
||||
<programlisting>
|
||||
|
||||
{* questo esempio stamper<65> tutti i valori dell'array $custid *}
|
||||
{section name=customer loop=$custid}
|
||||
id: {$custid[customer]}<br>
|
||||
{/section}
|
||||
|
||||
OUTPUT:
|
||||
|
||||
id: 1000<br>
|
||||
id: 1001<br>
|
||||
id: 1002<br></programlisting>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>variabile loop</title>
|
||||
<programlisting>
|
||||
{* la variabile loop determina soltanto il numero di cicli da ripetere.
|
||||
Potete accedere a qualsiasi variabile dal template della sezione.
|
||||
In questo esempio presumiamo che $custid, $name e $address siano
|
||||
tutti array contenenti lo stesso numero di valori *}
|
||||
{section name=customer loop=$custid}
|
||||
id: {$custid[customer]}<br>
|
||||
name: {$name[customer]}<br>
|
||||
address: {$address[customer]}<br>
|
||||
<p>
|
||||
{/section}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
|
||||
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>nomi delle sezioni</title>
|
||||
<programlisting>
|
||||
{* come nome della sezione potete usare quello che preferite,
|
||||
e viene usato per riferirsi ai dati all'interno della sezione *}
|
||||
{section name=mydata loop=$custid}
|
||||
id: {$custid[mydata]}<br>
|
||||
name: {$name[mydata]}<br>
|
||||
address: {$address[mydata]}<br>
|
||||
<p>
|
||||
{/section}</programlisting>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>sezioni nidificate</title>
|
||||
<programlisting>
|
||||
{* le sezioni possono essere nidificate a qualsiasi profondit<69>. Con
|
||||
le sezioni nidificate potete accedere a strutture di dati complesse,
|
||||
ad esempio array multidimensionali. In questo esempio, $contact_type[customer]
|
||||
<20> un array di tipi di contatto per il cliente corrente. *}
|
||||
{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}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
|
||||
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@myexample.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@myexample.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@myexample.com<br>
|
||||
<p></programlisting>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>sezioni e array associativi</title>
|
||||
<programlisting>
|
||||
{* questo <20> un esempio di stampa di un array associativo
|
||||
di dati in una sezione *}
|
||||
{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}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
|
||||
name: John Smith<br>
|
||||
home: 555-555-5555<br>
|
||||
cell: 555-555-5555<br>
|
||||
e-mail: john@myexample.com<p>
|
||||
name: Jack Jones<br>
|
||||
home phone: 555-555-5555<br>
|
||||
cell phone: 555-555-5555<br>
|
||||
e-mail: jack@myexample.com<p>
|
||||
name: Jane Munson<br>
|
||||
home phone: 555-555-5555<br>
|
||||
cell phone: 555-555-5555<br>
|
||||
e-mail: jane@myexample.com<p></programlisting>
|
||||
</example>
|
||||
|
||||
|
||||
|
||||
<example>
|
||||
<title>sectionelse</title>
|
||||
<programlisting>
|
||||
{* sectionelse viene eseguito se non ci sono valori in $custid *}
|
||||
{section name=customer loop=$custid}
|
||||
id: {$custid[customer]}<br>
|
||||
{sectionelse}
|
||||
there are no values in $custid.
|
||||
{/section}</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Le sezioni hanno anche le proprie variabili di gestione delle propriet<65>.
|
||||
Vengono indicate cos<6F>: {$smarty.section.nomesezione.nomevariabile}
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
A partire da Smarty 1.5.0, la sintassi per le variabili delle propriet<65>
|
||||
di sessione <20> cambiata da {%nomesezione.nomevariabile%} a
|
||||
{$smarty.section.sectionname.varname}. La vecchia sintassi <20> ancora
|
||||
supportata, ma negli esempi del manuale troverete solo riferimenti
|
||||
alla nuova.
|
||||
</para>
|
||||
</note>
|
||||
<sect2 id="section.property.index">
|
||||
<title>index</title>
|
||||
<para>
|
||||
index si usa per visualizzare l'attuale indice del ciclo, partendo
|
||||
da zero (o dall'attributo start se presente), e con incrementi di uno
|
||||
(o dell'attributo step se presente).
|
||||
</para>
|
||||
<note>
|
||||
<title>Nota tecnica</title>
|
||||
<para>
|
||||
Se le propriet<65> step e start non vengono modificate, index
|
||||
funziona allo stesso modo della propriet<65> iteration, ad
|
||||
eccezione del fatto che parte da 0 invece che da 1.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>propriet<EFBFBD> index</title>
|
||||
<programlisting>
|
||||
{section name=customer loop=$custid}
|
||||
{$smarty.section.customer.index} id: {$custid[customer]}<br>
|
||||
{/section}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
|
||||
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 visualizza l'indice del ciclo precedente.
|
||||
Sul primo ciclo <20> impostata a -1.
|
||||
</para>
|
||||
<example>
|
||||
<title>propriet<EFBFBD> index_prev</title>
|
||||
<programlisting>
|
||||
{section name=customer loop=$custid}
|
||||
{$smarty.section.customer.index} id: {$custid[customer]}<br>
|
||||
{* nota: $custid[customer.index] e $custid[customer] hanno identico significato *}
|
||||
{if $custid[customer.index_prev] ne $custid[customer.index]}
|
||||
The customer id changed<br>
|
||||
{/if}
|
||||
{/section}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
|
||||
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 visualizza l'indice del prossimo ciclo. Sull'ultimo
|
||||
ciclo ha sempre il valore maggiore dell'attuale (rispettando
|
||||
l'attributo step, quando presente).
|
||||
</para>
|
||||
<example>
|
||||
<title>propriet<EFBFBD> index_next</title>
|
||||
<programlisting>
|
||||
{section name=customer loop=$custid}
|
||||
{$smarty.section.customer.index} id: {$custid[customer]}<br>
|
||||
{* nota: $custid[customer.index] e $custid[customer] hanno identico significato *}
|
||||
{if $custid[customer.index_next] ne $custid[customer.index]}
|
||||
The customer id will change<br>
|
||||
{/if}
|
||||
{/section}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
|
||||
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 visualizza l'iterazione attuale del ciclo.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
Al contrario di index, questa propriet<65> non <20> influenzata dalle
|
||||
propriet<65> start, step e max. Inoltre iteration comincia da 1
|
||||
invece che da 0 come index. rownum <20> un alias di iteration, e
|
||||
funziona in modo identico.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>propriet<EFBFBD> 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>
|
||||
{* nota: $custid[customer.index] e $custid[customer] hanno identico significato *}
|
||||
{if $custid[customer.index_next] ne $custid[customer.index]}
|
||||
The customer id will change<br>
|
||||
{/if}
|
||||
{/section}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
|
||||
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 vale true se l'iterazione attuale <20> la prima.
|
||||
</para>
|
||||
<example>
|
||||
<title>propriet<EFBFBD> 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}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
|
||||
<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 vale true se l'attuale iterazione <20> l'ultima.
|
||||
</para>
|
||||
<example>
|
||||
<title>propriet<EFBFBD> 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}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
|
||||
<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 visualizza l'iterazione attuale del ciclo, partendo
|
||||
da uno. E' un alias di iteration, e funziona in modo identico.
|
||||
</para>
|
||||
<example>
|
||||
<title>propriet<EFBFBD> rownum</title>
|
||||
<programlisting>
|
||||
{section name=customer loop=$custid}
|
||||
{$smarty.section.customer.rownum} id: {$custid[customer]}<br>
|
||||
{/section}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
|
||||
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 visualizza l'index dell'ultimo ciclo visualizzato dalla
|
||||
sezione. Pu<50> essere usato all'interno o dopo la sezione.
|
||||
</para>
|
||||
<example>
|
||||
<title>propriet<EFBFBD> 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.
|
||||
|
||||
OUTPUT:
|
||||
|
||||
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> usato come parametro per la sezione.
|
||||
<emphasis>show</emphasis> <20> un valore booleano, true o false. Se
|
||||
false, la sezione non verr<72> visualizzata. Se <20> presente un sectionelse,
|
||||
verr<72> visualizzato questo.
|
||||
</para>
|
||||
<example>
|
||||
<title>attributo show</title>
|
||||
<programlisting>
|
||||
{* $show_customer_info potrebbe essere stato passato dall'applicazione
|
||||
PHP, per stabilire se questa sezione deve essere visualizzata o no *}
|
||||
{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}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
|
||||
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 visualizza il numero totale di iterazioni che la sezione
|
||||
eseguir<69>. Pu<50> essere usato all'interno o dopo la sezione.
|
||||
</para>
|
||||
<example>
|
||||
<title>propriet<EFBFBD> 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.
|
||||
|
||||
OUTPUT:
|
||||
|
||||
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
|
||||
-->
|
||||
@@ -0,0 +1,79 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.strip">
|
||||
<title>strip</title>
|
||||
<para>
|
||||
Molte volte i progettisti di pagine web si trovano davanti al
|
||||
problema causato da spazi e "a capo" che influiscono sull'output
|
||||
HTML generato (a causa delle "caratteristiche" del browser), per
|
||||
cui si trovano costretti a mettere tutti insieme i tag del template
|
||||
per ottenere il risultato voluto. Questo di solito significa
|
||||
ritrovarsi con un template illeggibile o ingestibile.
|
||||
</para>
|
||||
<para>
|
||||
Tutto ci<63> che <20> compreso fra i tag {strip}{/strip} in Smarty viene
|
||||
ripulito dagli spazi extra o dai caratteri di ritorno a capo all'inizio
|
||||
e alla fine delle righe, prima di essere visualizzato. In
|
||||
questo modo potete mantenere la leggibilit<69> dei vostri template senza
|
||||
preoccuparvi dei problemi causati dagli spazi.
|
||||
</para>
|
||||
<note>
|
||||
<title>Nota tecnica</title>
|
||||
<para>
|
||||
{strip}{/strip} non modificano il contenuto delle variabili del template.
|
||||
Vedere la <link linkend="language.modifier.strip">funzione strip modifier</link>.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>tag strip</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* il codice seguente uscir<69> in output su una riga unica *}
|
||||
{strip}
|
||||
<table border=0>
|
||||
<tr>
|
||||
<td>
|
||||
<A HREF="{$url}">
|
||||
<font color="red">This is a test</font>
|
||||
</A>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
{/strip}
|
||||
|
||||
|
||||
OUTPUT:
|
||||
|
||||
<table border=0><tr><td><A HREF="http://my.example.com"><font color="red">This is a test</font></A></td></tr></table>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Notate che nell'esempio qui sopra tutte le righe iniziano e
|
||||
finiscono con tag HTML. Tenete presente che tutte le linee
|
||||
vengono "attaccate", per cui se avete del testo all'inizio
|
||||
o alla fine di qualche riga, questo verr<72> attaccato, e probabilmente
|
||||
non <20> ci<63> che volete.
|
||||
</para>
|
||||
</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
|
||||
-->
|
||||
Reference in New Issue
Block a user