Files
smarty/docs/it/designers/language-modifiers/language-modifier-truncate.xml

119 lines
3.2 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision$ -->
<sect1 id="language.modifier.truncate">
<title>truncate</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>Posizione del Parametro</entry>
<entry>Tipo</entry>
<entry>Obbligatorio</entry>
<entry>Default</entry>
<entry>Descrizione</entry>
</row>
</thead>
<tbody>
<row>
<entry>1</entry>
<entry>intero</entry>
<entry>No</entry>
<entry>80</entry>
<entry>Stabilisce a quanti caratteri effettuare il troncamento.</entry>
</row>
<row>
<entry>2</entry>
<entry>stringa</entry>
<entry>No</entry>
<entry>...</entry>
<entry>Testo da aggiungere in fondo quando c'è troncamento.</entry>
</row>
<row>
<entry>3</entry>
<entry>booleano</entry>
<entry>No</entry>
<entry>false</entry>
<entry>Stabilisce se troncare dopo una parola (false), o al carattere
esatto (true).</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>
Effettua il troncamento di una variabile ad un certo numero di caratteri,
per default 80. Come secondo parametro opzionale potete specificare una
stringa di testo da mostrare alla fine se la variabile è stata troncata.
Questi caratteri non vengono conteggiati nella lunghezza della
stringa troncata. Per default, truncate cercherà di tagliare la stringa al
termine di una parola. Se invece volete effettuare il troncamento alla
lunghezza esatta in caratteri, passate il terzo parametro opzionale come true.
</para>
<example>
<title>truncate</title>
<programlisting role="php">
<![CDATA[
<?php
$smarty = new Smarty;
$smarty->assign('articleTitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.');
$smarty->display('index.tpl');
?>
]]>
</programlisting>
<para>
Dove index.tpl è:
</para>
<programlisting>
<![CDATA[
{$articleTitle}
{$articleTitle|truncate}
{$articleTitle|truncate:30}
{$articleTitle|truncate:30:""}
{$articleTitle|truncate:30:"---"}
{$articleTitle|truncate:30:"":true}
{$articleTitle|truncate:30:"...":true}
]]>
</programlisting>
<para>
Questo stamperà:
</para>
<screen>
<![CDATA[
Two Sisters Reunite after Eighteen Years at Checkout Counter.
Two Sisters Reunite after Eighteen Years at Checkout Counter.
Two Sisters Reunite after...
Two Sisters Reunite after
Two Sisters Reunite after---
Two Sisters Reunite after Eigh
Two Sisters Reunite after E...
]]>
</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
-->