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,173 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.assigned.variables">
|
||||
<title>Variabili valorizzate da PHP</title>
|
||||
<para>
|
||||
Le variabili valorizzate da PHP sono referenziate facendole precedere
|
||||
da un segno di dollaro <literal>$</literal>. Anche le variabili
|
||||
valorizzate internamente al template con la funzione <link
|
||||
linkend="language.function.assign">assign</link> vengono visualizzate
|
||||
in questo modo.
|
||||
</para>
|
||||
<example>
|
||||
|
||||
<title>variabili valorizzate</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
Hello {$firstname}, glad to see you could make it.
|
||||
<br />
|
||||
Your last login was on {$lastLoginDate}.
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Questo visualizzer<65>:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Hello Doug, glad to see you could make it.
|
||||
<br />
|
||||
Your last login was on January 11th, 2001.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
<sect2 id="language.variables.assoc.arrays">
|
||||
<title>Array associativi</title>
|
||||
<para>
|
||||
Potete fare riferimento ad array associativi valorizzati da
|
||||
PHP specificando l'indice dopo il punto '.'
|
||||
</para>
|
||||
<example>
|
||||
<title>accesso ad array associativi</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('Contacts',
|
||||
array('fax' => '555-222-9876',
|
||||
'email' => 'zaphod@slartibartfast.com',
|
||||
'phone' => array('home' => '555-444-3333',
|
||||
'cell' => '555-111-1234')));
|
||||
$smarty->display('index.tpl');
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
dove il contenuto di index.tpl <20>:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{$Contacts.fax}<br />
|
||||
{$Contacts.email}<br />
|
||||
{* ovviamente si possono usare anche array multidimensionali *}
|
||||
{$Contacts.phone.home}<br />
|
||||
{$Contacts.phone.cell}<br />
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
questo visualizzer<65>:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
555-222-9876<br />
|
||||
zaphod@slartibartfast.com<br />
|
||||
555-444-3333<br />
|
||||
555-111-1234<br />
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</sect2>
|
||||
<sect2 id="language.variables.array.indexes">
|
||||
<title>Array con indici numerici</title>
|
||||
<para>
|
||||
Potete referenziare gli array con il loro indice, come in PHP.
|
||||
</para>
|
||||
<example>
|
||||
<title>accesso agli array per indice numerico</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('Contacts',
|
||||
array('555-222-9876',
|
||||
'zaphod@slartibartfast.com',
|
||||
array('555-444-3333',
|
||||
'555-111-1234')));
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
dove index.tpl <20>:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{$Contacts[0]}<br />
|
||||
{$Contacts[1]}<br />
|
||||
{* anche qui si possono usare array multidimensionali *}
|
||||
{$Contacts[2][0]}<br />
|
||||
{$Contacts[2][1]}<br />
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Questo visualizzer<65>:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
555-222-9876<br />
|
||||
zaphod@slartibartfast.com<br />
|
||||
555-444-3333<br />
|
||||
555-111-1234<br />
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</sect2>
|
||||
<sect2 id="language.variables.objects">
|
||||
<title>Oggetti</title>
|
||||
<para>
|
||||
Le propriet<65> di oggetti valorizzate da PHP possono essere
|
||||
referenziate indicando il nome della propriet<65> dopo il
|
||||
simbolo '->'
|
||||
</para>
|
||||
<example>
|
||||
<title>accesso alle propriet<65> degli oggetti</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
name: {$person->name}<br />
|
||||
email: {$person->email}<br />
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Questo visualizzer<65>:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
name: Zaphod Beeblebrox<br />
|
||||
email: zaphod@slartibartfast.com<br />
|
||||
]]>
|
||||
</screen>
|
||||
</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,113 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.config.variables">
|
||||
<title>Variabili caricate da file di configurazione</title>
|
||||
<para>
|
||||
Le variabili caricate dai file di configurazione sono referenziate
|
||||
racchiudendole fra due simboli cancelletto (#), oppure attraverso
|
||||
la variabile <link
|
||||
linkend="language.variables.smarty.config">$smarty.config</link>.
|
||||
La seconda sintassi <20> utile per includerle in valori di attributi
|
||||
indicati fra virgolette.
|
||||
</para>
|
||||
<example>
|
||||
<title>variabili di configurazione</title>
|
||||
<para>
|
||||
foo.conf:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
pageTitle = "This is mine"
|
||||
bodyBgColor = "#eeeeee"
|
||||
tableBorderSize = "3"
|
||||
tableBgColor = "#bbbbbb"
|
||||
rowBgColor = "#cccccc"
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
index.tpl:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{config_load file="foo.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>
|
||||
<para>
|
||||
index.tpl: (sintassi alternativa)
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{config_load file="foo.conf"}
|
||||
<html>
|
||||
<title>{$smarty.config.pageTitle}</title>
|
||||
<body bgcolor="{$smarty.config.bodyBgColor}">
|
||||
<table border="{$smarty.config.tableBorderSize}" bgcolor="{$smarty.config.tableBgColor}">
|
||||
<tr bgcolor="{$smarty.config.rowBgColor}">
|
||||
<td>First</td>
|
||||
<td>Last</td>
|
||||
<td>Address</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
questo <20> l'output prodotto da entrambi gli esempi:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<html>
|
||||
<title>This is mine</title>
|
||||
<body bgcolor="#eeeeee">
|
||||
<table border="3" bgcolor="#bbbbbb">
|
||||
<tr bgcolor="#cccccc">
|
||||
<td>First</td>
|
||||
<td>Last</td>
|
||||
<td>Address</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
Le variabili dei file di configurazione non possono essere usate
|
||||
fino a dopo che sono state caricate dal file che le contiene.
|
||||
Questa procedura viene spiegata pi<70> avanti in questo documento,
|
||||
in <command>config_load</command>.
|
||||
</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,167 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.variables.smarty">
|
||||
<title>La variabile riservata {$smarty}</title>
|
||||
<para>
|
||||
La variabile riservata {$smarty} pu<70> essere usate per accedere
|
||||
a parecchie variabili speciali del template. Quella che segue
|
||||
<20> la lista completa.
|
||||
</para>
|
||||
|
||||
<sect2 id="language.variables.smarty.request">
|
||||
<title>Variabili della richiesta HTTP</title>
|
||||
<para>
|
||||
Alle variabili get, post, cookies, server,
|
||||
environment e session si pu<70> accedere come mostrato negli
|
||||
esempi qui sotto:
|
||||
</para>
|
||||
<example>
|
||||
<title>visualizzazione delle variabili request</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* visualizza il valore di "page" dall'URL (GET) http://www.example.com/index.php?page=foo *}
|
||||
{$smarty.get.page}
|
||||
|
||||
{* visualizza la variabile "page" da un modulo (POST) *}
|
||||
{$smarty.post.page}
|
||||
|
||||
{* visualizza il valore del cookie "username" *}
|
||||
{$smarty.cookies.username}
|
||||
|
||||
{* visualizza la variabile del server "SERVER_NAME" *}
|
||||
{$smarty.server.SERVER_NAME}
|
||||
|
||||
{* visualizza la variabile di ambiente "PATH" *}
|
||||
{$smarty.env.PATH}
|
||||
|
||||
{* visualizza la variabile di sessione PHP "id" *}
|
||||
{$smarty.session.id}
|
||||
|
||||
{* visualizza la variabile "username" dalla fusione di get/post/cookies/server/env *}
|
||||
{$smarty.request.username}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<note>
|
||||
<para>
|
||||
Per motivi storici si pu<70> accedere direttamente a {$SCRIPT_NAME},
|
||||
sebbene {$smarty.server.SCRIPT_NAME} sia la maniera consigliata
|
||||
per ottenere questo valore.
|
||||
</para>
|
||||
</note>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="language.variables.smarty.now">
|
||||
<title>{$smarty.now}</title>
|
||||
<para>
|
||||
Si pu<70> accedere al timestamp corrente con {$smarty.now}.
|
||||
Questo numero rappresenta il numero di secondi passati dalla
|
||||
cosiddetta Epoch (1<> gennaio 1970) e pu<70> essere passato
|
||||
direttamente al modificatore date_format per la visualizzazione.
|
||||
</para>
|
||||
<example>
|
||||
<title>uso di {$smarty.now}</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* uso del modificatore date_format per mostrare data e ora attuali *}
|
||||
{$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect2>
|
||||
<sect2 id="language.variables.smarty.const">
|
||||
<title>{$smarty.const}</title>
|
||||
<para>
|
||||
Pu<50> essere usato per accedere direttamente alle costanti PHP.
|
||||
</para>
|
||||
<example>
|
||||
<title>uso di {$smarty.const}</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{$smarty.const._MY_CONST_VAL}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="language.variables.smarty.capture">
|
||||
<title>{$smarty.capture}</title>
|
||||
<para>
|
||||
Si pu<70> accedere all'output catturato attraverso il costrutto
|
||||
{capture}..{/capture} con la variabile {$smarty}. Consultare
|
||||
la sezione <link linkend="language.function.capture">capture</link>
|
||||
per avere un esempio.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="language.variables.smarty.config">
|
||||
<title>{$smarty.config}</title>
|
||||
<para>
|
||||
La variabile {$smarty} pu<70> essere usata per referenziare le
|
||||
variabili di configurazione caricate. {$smarty.config.foo}
|
||||
<20> sinonimo di {#foo#}. Consultare la sezione
|
||||
<link linkend="language.function.config.load">config_load</link>
|
||||
per avere un esempio.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="language.variables.smarty.loops">
|
||||
<title>{$smarty.section}, {$smarty.foreach}</title>
|
||||
<para>
|
||||
La variabile {$smarty} pu<70> essere usata per referenziare
|
||||
le propriet<65> dei loop 'section' e 'foreach'. Vedere la documentazione
|
||||
di <link linkend="language.function.section">section</link> e
|
||||
<link linkend="language.function.foreach">foreach</link>.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="language.variables.smarty.template">
|
||||
<title>{$smarty.template}</title>
|
||||
<para>
|
||||
Questa variabile contiene il nome del template attualmente in fase di elaborazione.
|
||||
</para>
|
||||
</sect2>
|
||||
<sect2 id="language.variables.smarty.version">
|
||||
<title>{$smarty.version}</title>
|
||||
<para>
|
||||
Questa variabile contiene la versione di Smarty con cui il template <20> stato compilato.
|
||||
</para>
|
||||
</sect2>
|
||||
<sect2 id="language.variables.smarty.ldelim">
|
||||
<title>{$smarty.ldelim}</title>
|
||||
<para>
|
||||
Questa variabile <20> usata per stampare il delimitatore sinistro di Smarty in modo
|
||||
letterale, cio<69> senza che venga interpretato come tale. Vedere anche
|
||||
<link linkend="language.function.ldelim">{ldelim},{rdelim}</link>.
|
||||
</para>
|
||||
</sect2>
|
||||
<sect2 id="language.variables.smarty.rdelim">
|
||||
<title>{$smarty.rdelim}</title>
|
||||
<para>
|
||||
Questa variabile <20> usata per stampare il delimitatore destro di Smarty in modo
|
||||
letterale, cio<69> senza che venga interpretato come tale. Vedere anche
|
||||
<link linkend="language.function.ldelim">{ldelim},{rdelim}</link>.
|
||||
</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
|
||||
-->
|
||||
Reference in New Issue
Block a user