mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-12 09:59:53 +01:00
120 lines
3.2 KiB
XML
120 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>Posici<EFBFBD>n del Parametro</entry>
|
|||
|
|
<entry>Tipo</entry>
|
|||
|
|
<entry>Requerido</entry>
|
|||
|
|
<entry>Default</entry>
|
|||
|
|
<entry>Desdcripci<EFBFBD>n</entry>
|
|||
|
|
</row>
|
|||
|
|
</thead>
|
|||
|
|
<tbody>
|
|||
|
|
<row>
|
|||
|
|
<entry>1</entry>
|
|||
|
|
<entry>integer</entry>
|
|||
|
|
<entry>No</entry>
|
|||
|
|
<entry>80</entry>
|
|||
|
|
<entry>Este determina para cuantos car<61>cteres truncar.</entry>
|
|||
|
|
</row>
|
|||
|
|
<row>
|
|||
|
|
<entry>2</entry>
|
|||
|
|
<entry>string</entry>
|
|||
|
|
<entry>No</entry>
|
|||
|
|
<entry>...</entry>
|
|||
|
|
<entry>Este es el texto para adicionar si el truncamiento ocurre.</entry>
|
|||
|
|
</row>
|
|||
|
|
<row>
|
|||
|
|
<entry>3</entry>
|
|||
|
|
<entry>boolean</entry>
|
|||
|
|
<entry>No</entry>
|
|||
|
|
<entry>false</entry>
|
|||
|
|
<entry>Este determina cuando truncar o no o al final de una
|
|||
|
|
palabra(false), o un car<61>cter exacto(true).
|
|||
|
|
</entry>
|
|||
|
|
</row>
|
|||
|
|
</tbody>
|
|||
|
|
</tgroup>
|
|||
|
|
</informaltable>
|
|||
|
|
<para>
|
|||
|
|
Este trunca la variable en una cantidad de cacarteres, el default es 80.
|
|||
|
|
Como segundo par<61>metro opcional, usted puede especificar una cadena
|
|||
|
|
para mostrar al final si la variable fue truncada. Los car<61>cteres en la
|
|||
|
|
cadena son incluidos tamando el original para el truncamiento.
|
|||
|
|
Por default, truncate intentara cortar al final de una palabra.
|
|||
|
|
Se usted quisiera cortar una cantidad exacta de car<61>cteres, pase el
|
|||
|
|
tercer par<61>metro, que es opcional, como 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>
|
|||
|
|
Donde index.tpl es:
|
|||
|
|
</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>
|
|||
|
|
Esta es la Salida:
|
|||
|
|
</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
|
|||
|
|
-->
|