mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-07 03:44:26 +02:00
huge sync with english by the translator (Mario Ramirez)
thanks
This commit is contained in:
@@ -11,8 +11,9 @@
|
||||
usted def<65>ne a una variable vacia en vez de imprimir nada, tal
|
||||
como imprimir "&nbsp;" a fin de que el plano del fondo de
|
||||
la tabla funcione correctamente. Muchos usarian una sentencia
|
||||
{if} para manejar esto, mas existe otra forma con Smarty, usando
|
||||
el modificador de la variable <emphasis>default</emphasis>.
|
||||
<link linkend="language.function.if">{if}</link> para manejar esto,
|
||||
mas existe otra forma con Smarty, usando el modificador de la variable
|
||||
<link linkend="language.modifier.default"><emphasis>default</emphasis></link>.
|
||||
</para>
|
||||
<example>
|
||||
<title>Imprimiendo &nbsp; cuando una variable esta vacia</title>
|
||||
@@ -33,6 +34,10 @@
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambien <link linkend="language.modifier.default">default</link>
|
||||
y <link linkend="tips.default.var.handling">Default Variable Handling</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<sect1 id="tips.default.var.handling">
|
||||
@@ -43,7 +48,7 @@
|
||||
mencionado puede evitar un bit desagradable. Usted puede
|
||||
remediar esto con la atribuci<63>n de un valor por default a
|
||||
la variable con la funci<63>n
|
||||
<link linkend="language.function.assign">assign</link>.
|
||||
<link linkend="language.function.assign">{assign}</link>.
|
||||
</para>
|
||||
<example>
|
||||
<title>Atribuyendo el valor por default a una variable en el template</title>
|
||||
@@ -58,62 +63,79 @@ usted lo exiba *}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Vea tambi<62>en <link linkend="language.modifier.default">default</link> y
|
||||
<link linkend="tips.blank.var.handling">Blank Variable Handling</link>.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
<sect1 id="tips.passing.vars">
|
||||
<title>Pasando la variable titulo a la cabecera del template</title>
|
||||
<para>
|
||||
Cuando la mayoria de sus templates usan los mismo encabezados y
|
||||
los mismos pies de pagina, es com<6F>n dividirlos uno en cada template
|
||||
y entonces incluirlos. Que pasara si el encabezado necesita tener
|
||||
un titulo diferente, dependiendo de que pagina estas viniendo?
|
||||
usted puede pasar el titulo en el encabezado cuando este es incluido.
|
||||
y entonces incluirlos <link linkend="language.function.include">{include}</link>.
|
||||
Que pasara si el encabezado necesita tener un titulo diferente,
|
||||
dependiendo de que pagina estas viniendo? usted puede pasar el
|
||||
titulo en el encabezado cuando este es incluido.
|
||||
</para>
|
||||
<example>
|
||||
<title>Pasando la variable titulo al encabezado del template</title>
|
||||
<para>
|
||||
<filename>mainpage.tpl</filename>
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
mainpage.tpl
|
||||
------------
|
||||
|
||||
{include file="header.tpl" title="Main Page"}
|
||||
{* El cuerpo del template viene aqu<71> *}
|
||||
{* template body goes here *}
|
||||
{include file="footer.tpl"}
|
||||
|
||||
|
||||
archives.tpl
|
||||
------------
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
<filename>archives.tpl</filename>
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
|
||||
{config_load file="archive_page.conf"}
|
||||
{include file="header.tpl" title=#archivePageTitle#}
|
||||
{* El cuerpo del template viene aqu<71> *}
|
||||
{* template body goes here *}
|
||||
{include file="footer.tpl"}
|
||||
|
||||
|
||||
header.tpl
|
||||
----------
|
||||
<HTML>
|
||||
<HEAD>
|
||||
<TITLE>{$title|default:"BC News"}</TITLE>
|
||||
</HEAD>
|
||||
<BODY>
|
||||
|
||||
|
||||
footer.tpl
|
||||
----------
|
||||
</BODY>
|
||||
</HTML>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
<filename>header.tpl</filename>
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
<html>
|
||||
<head>
|
||||
<title>{$title|default:"BC News"}</title>
|
||||
</head>
|
||||
<body>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
<filename>footer.tpl</filename>
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
</body>
|
||||
</html>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Cuando la pagina principal es mostrada, el titulo de la "P<>gina
|
||||
Principal" es pasado al template header.tpl, y ser<65> posteriormente
|
||||
usado como el titulo. Cuando la pagina de archivo es mostrada, el
|
||||
titulo sera "Archivos". Observelo en el ejemplo de archivo, nosotros
|
||||
estamos usando una variable del archivo archives_page.conf en vez de
|
||||
una variable codificada rigida. Tambien note que "BC news" es mostrada
|
||||
si la variable $titulo no esta definida, usando el modificador de la
|
||||
variable <emphasis>default</emphasis>.
|
||||
Principal" es pasado al template <filename>header.tpl</filename>,
|
||||
y ser<65> posteriormente usado como el titulo. Cuando la pagina de archivo
|
||||
es mostrada, el titulo sera "Archivos". Observelo en el ejemplo de archivo,
|
||||
nosotros estamos usando una variable del archivo
|
||||
<filename>archives_page.conf</filename> en vez de una variable codificada
|
||||
rigida. Tambien note que "BC news" es mostrada si la variable $titulo no
|
||||
esta definida, usando el modificador de la variable
|
||||
<link linkend="language.modifier.default">default</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<sect1 id="tips.dates">
|
||||
@@ -129,7 +151,7 @@ footer.tpl
|
||||
<para>
|
||||
En el Smarty 1.4.0, usted puede parsar fechas al Smarty como
|
||||
timestamps unix,mysql, o cualquier otra fecha interpretable
|
||||
por strtotime().
|
||||
por <ulink url="&url.php-manual;strtotime">strtotime()</ulink>.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
@@ -169,10 +191,10 @@ Jan 4, 2001
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Cuando usa {html_select_date} en un template, el programador
|
||||
normalmente va a querer convertir la salida de un formulario
|
||||
de vuelta al formato timestamp. Aqu<71> esta una funci<63>n para
|
||||
ayudar con esto.
|
||||
Cuando usa <link linkend="language.function.html.select.date">{html_select_date}</link>
|
||||
en un template, el programador normalmente va a querer convertir
|
||||
la salida de un formulario de vuelta al formato timestamp. Aqu<71>
|
||||
esta una funci<63>n para ayudar con esto.
|
||||
</para>
|
||||
<example>
|
||||
<title>Convirtiendo elementos en forma de fecha de vuelta a un timestamp</title>
|
||||
@@ -202,18 +224,28 @@ function makeTimeStamp($year="", $month="", $day="")
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Vea tambi<62>n
|
||||
<link linkend="language.function.html.select.date">{html_select_date}</link>,
|
||||
<link linkend="language.function.html.select.time">{html_select_time}</link>,
|
||||
<link linkend="language.modifier.date.format">date_format</link>
|
||||
y <link linkend="language.variables.smarty.now">$smarty.now</link>,
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
<sect1 id="tips.wap">
|
||||
<title>WAP/WML</title>
|
||||
<para>
|
||||
Los templates WAP/WML requieren de un encabezado de Content-Type de
|
||||
Los templates WAP/WML requieren de un encabezado de
|
||||
<ulink url="&url.php-manual;header">Content-Type</ulink> de
|
||||
PHP para ser pasado junto con el template. La forma mas f<>cil de
|
||||
hacer esto seria escribir una funci<63>n de manera habitual que imprima
|
||||
el encabezado. Si usted esta usando el sistema de cache, este no
|
||||
funcionara, entonces nosotros haremos esto usando una etiqueta de
|
||||
insert (recuerde que las etiquetas insert no son "cacheadas!").
|
||||
Asegurarse que no exista ninguna salida al navegador antes del template,
|
||||
de otro modo el encabezado fallara.
|
||||
el encabezado. Si usted esta usando el sistema de
|
||||
<link linkend="caching">cache</link>, este no funcionara, entonces
|
||||
nosotros haremos esto usando una etiqueta de
|
||||
<link linkend="language.function.insert">{insert}</link> (recuerde que
|
||||
las etiquetas insert no son "cacheadas!"). Asegurarse que no exista
|
||||
ninguna salida al navegador antes del template, de otro modo el encabezado fallara.
|
||||
</para>
|
||||
<example>
|
||||
<title>Usando insert para escribir un encabezado WML Content-Type</title>
|
||||
@@ -273,12 +305,14 @@ Pretty easy isn't it?
|
||||
<sect1 id="tips.componentized.templates">
|
||||
<title>Templates con Componetes</title>
|
||||
<para>
|
||||
Tradicionalmente, programar templates en sus aplicaciones sigue
|
||||
esta forma: Primero, usted acumula sus variables dentro de su
|
||||
Tradicionalmente, programar templates en sus aplicaciones es de
|
||||
la siguiente forma: Primero, usted acumula sus variables dentro de su
|
||||
aplicaci<63>n PHP, (talvez como requisiciones de una base de datos).
|
||||
Entonces, usted instancia su objeto Smarty, atribuye valores a
|
||||
las variables y muestra el template. Por ejemplo nosotros tenemos
|
||||
un registrador de existencias en nuestro template. Nosotros
|
||||
Entonces, usted instancia su objeto Smarty
|
||||
<link linkend="api.assign">assign()</link>, atribuye valores a
|
||||
las variables y muestra el template
|
||||
<link linkend="api.display">display()</link>. Por ejemplo nosotros
|
||||
tenemos un registrador de existencias en nuestro template. Nosotros
|
||||
recolectaremos los datos de las existencias en nuestra aplicaci<63>n,
|
||||
entonces damos valor a estas variables en el template y lo mostramos.
|
||||
Ahora esto seria genial si usted adicionara este registrador de
|
||||
@@ -292,11 +326,16 @@ Pretty easy isn't it?
|
||||
</para>
|
||||
<example>
|
||||
<title>Templates con Componetes</title>
|
||||
<para>
|
||||
<filename>function.load_ticker.php</filename> -
|
||||
deja el archivo en
|
||||
<link linkend="variable.plugins.dir">$plugins directory</link>
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
// drop file "function.load_ticker.php" in plugin directory
|
||||
// deja el archivo "function.load_ticker.php" en el directorio de plugins
|
||||
|
||||
// configura nuestra función para traer los datos almacenados
|
||||
function fetch_ticker($symbol)
|
||||
@@ -317,19 +356,23 @@ function smarty_function_load_ticker($params, &$smarty)
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
<filename>index.tpl</filename>
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
index.tpl
|
||||
---------
|
||||
|
||||
{* Smarty *}
|
||||
|
||||
{load_ticker symbol="YHOO" assign="ticker"}
|
||||
|
||||
Stock Name: {$ticker.name} Stock Price: {$ticker.price}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Vea tambi<62>n <link linkend="language.function.include.php">{include_php}</link>,
|
||||
<link linkend="language.function.include">{include}</link> y
|
||||
<link linkend="language.function.php">{php}</link>.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
<sect1 id="tips.obfuscating.email">
|
||||
<title>Ofuscando direcciones de E-mail</title>
|
||||
@@ -340,14 +383,14 @@ Stock Name: {$ticker.name} Stock Price: {$ticker.price}
|
||||
combatir este problema, usted puede hacer que su direccion de
|
||||
E-mail aparesca en javascript mostrado en el codigo HTML, este
|
||||
mismo aparecera y funcionara correctamente en el navegador.
|
||||
Esto se puede hacer con el plugin mailto.
|
||||
Esto se puede hacer con el plugin
|
||||
<link linkend="language.function.mailto">{mailto}</link>.
|
||||
</para>
|
||||
<example>
|
||||
<title>Ejemplo de ofuscamiento de una direccion de E-mail</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
index.tpl
|
||||
---------
|
||||
{* in index.tpl *}
|
||||
|
||||
Send inquiries to
|
||||
{mailto address=$EmailAddress encode="javascript" subject="Hello"}
|
||||
@@ -362,6 +405,10 @@ Send inquiries to
|
||||
valores, mas no es muy com<6F>n.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
Vea tambi<62>n <link linkend="language.modifier.escape">escape</link>
|
||||
y <link linkend="language.function.mailto">{mailto}</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
</chapter>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -49,10 +49,111 @@ Parse error: parse error in /path/to/smarty/templates_c/index.tpl.php on line 75
|
||||
linea de error corresponde al script PHP compilado, no al template
|
||||
en si. Normalmente usted puede en el template localizar el error de
|
||||
sinxis. Algunas cosas que usted puede buscar: falta de cierre de
|
||||
etiquetas para {if}{/if} o {section}{/section}, o sintaxis de la
|
||||
l<EFBFBD>gica dentro de una etiqueta {if}. Si usted no encuentra el error,
|
||||
usted tendra que abrir el archivo PHP compilado y dirigirse al n<>mero
|
||||
de linea mostrado, donde el correspondiente error esta en el template.
|
||||
etiquetas para <link linkend="language.function.if">{if}{/if}}</link>
|
||||
o <link linkend="language.function.if">{section}{/section}</link>, o
|
||||
sintaxis de la l<>gica dentro de una etiqueta {if}. Si usted no encuentra
|
||||
el error, usted tendra que abrir el archivo PHP compilado y dirigirse al
|
||||
n<>mero de linea mostrado, donde el correspondiente error esta en el template.
|
||||
</para>
|
||||
<example>
|
||||
<title>Otros errores comunes</title>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Warning: Smarty error: unable to read resource: "index.tpl" in...
|
||||
or
|
||||
Warning: Smarty error: unable to read resource: "site.conf" in...
|
||||
]]>
|
||||
</screen>
|
||||
<para>
|
||||
<itemizedlist>
|
||||
<listitem>
|
||||
<para>
|
||||
El <link linkend="variable.template.dir">$template_dir</link>
|
||||
no existe o es incorrecto, o
|
||||
el archivo <filename>index.tpl</filename> no esta en la carpeta
|
||||
<filename class="directory">templates/</filename>
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
La funci<63>n <link linkend="language.function.config.load">{config_load}</link>
|
||||
esta dentro del template (o <link linkend="api.config.load">config_load()</link>
|
||||
habia sido llamado) y cualquira de los dos
|
||||
<link linkend="variable.config.dir">$config_dir</link>
|
||||
es incorrecto, no exista o
|
||||
<filename>site.conf</filename> no existe en el directorio.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
|
||||
</listitem><listitem>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Fatal error: Smarty error: the $compile_dir 'templates_c' does not exist,
|
||||
or is not a directory...
|
||||
]]>
|
||||
</screen>
|
||||
<para>
|
||||
Cualquiera de las dos el
|
||||
<link linkend="variable.compile.dir">$compile_dir</link>
|
||||
es asignado incorrectamente, el directorio no existe,
|
||||
o <filename>templates_c</filename> es un archivo y no un directorio.
|
||||
</para>
|
||||
</listitem><listitem>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Fatal error: Smarty error: unable to write to $compile_dir '....
|
||||
]]>
|
||||
</screen>
|
||||
<para>
|
||||
El <link linkend="variable.compile.dir">$compile_dir</link>
|
||||
no puede ser reescrito por el servidor web. Vea a fondo la pagina de permisos del
|
||||
<link linkend="installing.smarty.basic">instalaci<EFBFBD>n de smarty</link>.
|
||||
</para>
|
||||
|
||||
</listitem><listitem>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Fatal error: Smarty error: the $cache_dir 'cache' does not exist,
|
||||
or is not a directory. in /..
|
||||
]]>
|
||||
</screen>
|
||||
<para>
|
||||
Esto significa que
|
||||
<link linkend="variable.caching">$caching</link> es habilitado y
|
||||
cualquiera de los dos; el
|
||||
<link linkend="variable.cache.dir">$cache_dir</link>
|
||||
es asignado incorrectamente, o el directorio no existe,
|
||||
o <filename>cache</filename> es un archivo y no un directorio.
|
||||
</para>
|
||||
|
||||
</listitem><listitem>
|
||||
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Fatal error: Smarty error: unable to write to $cache_dir '/...
|
||||
]]>
|
||||
</screen>
|
||||
<para>
|
||||
Esto significa que
|
||||
<link linkend="variable.caching">$caching</link> es habilitado y el
|
||||
<link linkend="variable.cache.dir">$cache_dir</link>
|
||||
no puede ser rescrito por el web server. Ver ampliamente la pagina de permisos de
|
||||
<link linkend="installing.smarty.basic">la instalacion de smarty</link>.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
Vea tambi<62>n
|
||||
<link linkend="chapter.debugging.console">debugging</link>,
|
||||
<link linkend="variable.error.reporting">$error_reporting</link>
|
||||
y <link linkend="api.trigger.error">trigger_error()</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
</chapter>
|
||||
|
@@ -8,8 +8,10 @@
|
||||
las variables de archivos de configuraci<63>n de la llamada actual del
|
||||
template. Incluso un template llamado "debug.tpl" viene con la
|
||||
distribuci<63>n de Smarty el cual controla el formateo de la consola.
|
||||
Defina $debugging en true en el Smarty, y si es necesario defina
|
||||
$debug_tpl para la ruta del recurso debug.tpl (Esto es SMARTY_DIR por
|
||||
Defina <link linkend="variable.debugging">$debugging</link> en true en
|
||||
el Smarty, y si es necesario defina
|
||||
<link linkend="variable.debug.tpl">$debug_tpl</link> para la ruta
|
||||
del recurso debug.tpl (Esto es SMARTY_DIR por
|
||||
default). Cuando usted carga una pagina, una consola en javascript
|
||||
abrira una ventana popup y dara a usted el nombre de todos los templates
|
||||
incluidos y las variables definidas en la pagina actual. Para ver las
|
||||
@@ -23,8 +25,10 @@
|
||||
<note>
|
||||
<title>Nota T<>cnica</title>
|
||||
<para>
|
||||
La consola de debug no funciona cuando usted usa la API fetch(), solo
|
||||
cuando estuviera usando display(). Es un conjunto de comandos javascript
|
||||
La consola de debug no funciona cuando usted usa la API <link
|
||||
linkend="api.fetch">fetch()</link>, solo cuando estuviera usando
|
||||
<link linkend="api.display">display()</link>.
|
||||
Es un conjunto de comandos javascript
|
||||
adicionados al final del template generado. Si a usted no le gusta el
|
||||
javascript, usted puede editar el template debug.tpl para formatear la
|
||||
salida como usted quiera. Los datos del debug no son guardados en cache
|
||||
@@ -37,6 +41,13 @@
|
||||
son en segundos, o en fracciones de segundo.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
Vea tambi<62>n
|
||||
<link linkend="troubleshooting">troubleshooting</link>,
|
||||
<link linkend="variable.error.reporting">$error_reporting</link>
|
||||
y <link linkend="api.trigger.error">trigger_error()</link>.
|
||||
</para>
|
||||
|
||||
</chapter>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -64,10 +64,13 @@ pass=foobar
|
||||
</para>
|
||||
<para>
|
||||
Los archivos de configuraci<63>n son cargados en el template con una
|
||||
funci<63>n incrustada <command>config_load</command>.
|
||||
funci<63>n incrustada <link linkend="language.function.config.load">
|
||||
<command>{config_load}</command></link>.
|
||||
(Ver Tambi<62>n <link linkend="api.config.load"><command>config_load()</command></link> ).
|
||||
|
||||
</para>
|
||||
<para>
|
||||
Usted puede esconder variables o secciones enteras colocando un punto
|
||||
Usted puede ocultar variables o secciones enteras colocando un punto
|
||||
antes del nombre de la variable. Esto es <20>til si su aplicaci<63>n lee los
|
||||
archivos de configuraci<63>n y los datos sensibles a partir de ellos que
|
||||
la herramienta del template no lo necesita. Si usted tiene a otras
|
||||
@@ -75,6 +78,14 @@ pass=foobar
|
||||
que ellos no leeran datos sensibles del archivo de configuraci<63>n
|
||||
cargando estos en el template.
|
||||
</para>
|
||||
<para>
|
||||
Ver Tambi<62>n <link
|
||||
linkend="language.function.config.load">{config_load}</link>, <link
|
||||
linkend="variable.config.overwrite">$config_overwrite</link>, <link
|
||||
linkend="api.get.config.vars">get_config_vars()</link>, <link
|
||||
linkend="api.clear.config">clear_config()</link> y <link
|
||||
linkend="api.config.load">config_load()</link>
|
||||
</para>
|
||||
</chapter>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -5,7 +5,8 @@
|
||||
<para>
|
||||
Todas las etiquetas del template deben estar marcadas por delimitadores.
|
||||
Por default , estos delimitadores son <literal>{</literal>
|
||||
y <literal>}</literal>, sino estos pueden cambiar.
|
||||
y <literal>}</literal>, sino estos pueden
|
||||
<link linkend="variable.left.delimiter">cambiar</link>.
|
||||
</para>
|
||||
<para>
|
||||
Para estos ejemplos, nosotros asumiremos que usted est<73> usando los
|
||||
@@ -16,6 +17,7 @@
|
||||
</para>
|
||||
|
||||
&designers.language-basic-syntax.language-syntax-comments;
|
||||
&designers.language-basic-syntax.language-syntax-variables;
|
||||
&designers.language-basic-syntax.language-syntax-functions;
|
||||
&designers.language-basic-syntax.language-syntax-attributes;
|
||||
&designers.language-basic-syntax.language-syntax-quotes;
|
||||
|
@@ -7,7 +7,8 @@
|
||||
ingonar sections o algun otro tipo analisis de sintaxis. Un ejemplo clasico
|
||||
es con el codigo JavaScript o CSS incrustado en el template. El problema se
|
||||
origina cuando aquellos lenguajes que utilizan los caracteres { y } los
|
||||
cuales son tambi<62>n los delimitadores por default para Smarty.
|
||||
cuales son tambi<62>n los <link
|
||||
linkend="language.function.ldelim">delimitadores</link> por default para Smarty.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
@@ -22,8 +23,7 @@
|
||||
Similar a usar entidades HTML, usted puede usar <link
|
||||
linkend="language.function.ldelim">{ldelim}</link>,<link
|
||||
linkend="language.function.ldelim">{rdelim}</link> o <link
|
||||
linkend="language.variables.smarty.ldelim">{$smarty.ldelim}</link>,<link
|
||||
linkend="language.variables.smarty.rdelim">{$smarty.rdelim}</link>
|
||||
linkend="language.variables.smarty.ldelim">{$smarty.ldelim}</link>
|
||||
para mostrar los delimitadores actuales.
|
||||
</para>
|
||||
|
||||
@@ -62,6 +62,9 @@ dosomething();
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Ver Tambi<62>n <link linkend="language.modifier.escape">escape modifier</link>
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -26,6 +26,11 @@
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
Ver tambi<62>n la funci<63>n<link linkend="language.function.math">{math}</link>.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -3,7 +3,8 @@
|
||||
<sect1 id="language.syntax.attributes">
|
||||
<title>Atributos</title>
|
||||
<para>
|
||||
La mayoria de las funciones llevan atributos que especifican o
|
||||
La mayoria de las <link linkend="language.syntax.functions">funciones</link>
|
||||
llevan atributos que especifican o
|
||||
cambian su funcionamiento. Los atributos para las funciones de
|
||||
Smarty son muy parecidos a los atributos de HTML. Los valores
|
||||
estaticos no necesitan estar entre comillas, pero si es recomendado
|
||||
@@ -23,14 +24,16 @@
|
||||
<![CDATA[
|
||||
{include file="header.tpl"}
|
||||
|
||||
{include file="header.tpl" attrib_name="attrib value"}
|
||||
|
||||
{include file=$includeFile}
|
||||
|
||||
{include file=#includeFile#}
|
||||
{include file=#includeFile# title="Smarty is cool"}
|
||||
|
||||
{html_select_date display_days=yes}
|
||||
|
||||
<select name="company">
|
||||
{html_options values=$vals selected=$selected output=$output}
|
||||
{html_options options=$choices selected=$selected}
|
||||
</select>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
@@ -7,25 +7,34 @@
|
||||
los delimitadores, as<61>: {* este es un comentario *}.
|
||||
Los comentarios en Smarty no son mostrados en la salida final del
|
||||
template.
|
||||
semejantes a <!-- HTML comments -->
|
||||
Estos son usados para hacer notas internas dentro del template.
|
||||
</para>
|
||||
<example>
|
||||
<title>Comentarios</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* Smarty *}
|
||||
<body>
|
||||
{* this multiline
|
||||
comment is
|
||||
not sent to browser
|
||||
*}
|
||||
|
||||
{* include the header file here *}
|
||||
{include file="header.tpl"}
|
||||
|
||||
|
||||
{* Dev note: $includeFile is assigned foo.php script *}
|
||||
<!-- this html comment is sent to browser -->
|
||||
{include file=$includeFile}
|
||||
|
||||
{include file=#includeFile#}
|
||||
|
||||
{* display dropdown lists *}
|
||||
<select name="company">
|
||||
{html_options values=$vals selected=$selected output=$output}
|
||||
{html_options options=$vals selected=$selected_id}
|
||||
</select>
|
||||
</body>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
@@ -6,7 +6,8 @@
|
||||
Cada etiqueta Smarty muestra una
|
||||
<link linkend="language.variables">variable</link> o utiliza alg<6C>n
|
||||
tipo de funci<63>n. Las funciones son procesadas y mostradas colocando
|
||||
los atributos de la funci<63>n entre delimitadores, as<61>:
|
||||
los <link linkend="language.syntax.attributes">atributos</link> de
|
||||
la funci<63>n entre delimitadores, as<61>:
|
||||
{funcname attr1="val" attr2="val"}.
|
||||
</para>
|
||||
<example>
|
||||
@@ -29,14 +30,20 @@
|
||||
</example>
|
||||
<para>
|
||||
Las funciones internas y las funciones habituales, ambas deben tener
|
||||
la misma sintaxis dentro del template. Las funciones internas que
|
||||
funcionan en Smarty, son: <command>if</command>,
|
||||
<command>section</command> y <command>strip</command>.
|
||||
Estas no pueden ser modificadas. Las funciones habituales son
|
||||
funciones adicionales implementadas por plugins. Estas si pueden
|
||||
la misma sintaxis dentro del template. Las funciones <emphasis
|
||||
role="bold">internas</emphasis> que
|
||||
funcionan en Smarty, son:
|
||||
<link linkend="language.function.if">{if}</link>,
|
||||
<link linkend="language.function.section">{section}</link> y
|
||||
<link linkend="language.function.strip">{strip}</link>.
|
||||
Estas no pueden ser modificadas.
|
||||
Las funciones habituales son
|
||||
funciones <emphasis role="bold">adicionales</emphasis> implementadas
|
||||
por <link linkend="plugins">plugins</link>. Estas si pueden
|
||||
ser modificadas como usted quiera, o usted tambi<62>n puede
|
||||
adicionar nuevas.
|
||||
<command>html_options</command> y <command>html_select_date</command>
|
||||
<link linkend="language.function.html.options">{html_options}</link> y
|
||||
<link linkend="language.function.popup">{popup}</link>
|
||||
son ejemplos de funciones habituales.
|
||||
</para>
|
||||
</sect1>
|
||||
|
@@ -3,10 +3,14 @@
|
||||
<sect1 id="language.syntax.quotes">
|
||||
<title>Colocando variables entre comillas dobles</title>
|
||||
<para>
|
||||
Smarty puede reconocer variables asignadas entre comillas aunque estas
|
||||
Smarty puede reconocer <link linkend="language.syntax.variables">variables</link>
|
||||
<link linkend="api.assign">asignadas</link> entre comillas aunque estas
|
||||
solo tengan n<>meros, letras, guiones bajos y corchetes[].
|
||||
Con cualquier otro car<61>cter(puntos, referencia de objetos, etc.) las
|
||||
variables deben estar entre apostrofos.
|
||||
Usted no puede incrustar <link linkend="language.modifiers">modificadores</link>,
|
||||
Estos deben ser siempre aplicados fuera de las comillas.
|
||||
|
||||
</para>
|
||||
<example>
|
||||
<title>Sintaxis entre comillas</title>
|
||||
@@ -19,6 +23,7 @@ SYNTAX EXAMPLES:
|
||||
{func var="test $foo[bar] test"} <-- sees $foo[bar]
|
||||
{func var="test $foo.bar test"} <-- sees $foo (not $foo.bar)
|
||||
{func var="test `$foo.bar` test"} <-- sees $foo.bar
|
||||
{func var="test `$foo.bar` test"|escape} <-- modifiers outside quotes!
|
||||
|
||||
PRACTICAL EXAMPLES:
|
||||
{include file="subdir/$tpl_name.tpl"} <-- will replace $tpl_name with value
|
||||
@@ -26,6 +31,10 @@ PRACTICAL EXAMPLES:
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="language.modifier.escape">escape</link>.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -4,13 +4,15 @@
|
||||
<sect1 id="language.syntax.variables">
|
||||
<title>Variables</title>
|
||||
<para>
|
||||
Las variable de Template que comiencen con signo de pesos. Pueden contener n<>meros,
|
||||
letras y guiones bajos, muy parecido a las variables de PHP. Usted tambi<62>n puede
|
||||
hacer referencia a arreglos que puden ser numericos o no-numericos. Tambi<62>n
|
||||
puede hacer referencia a m<EFBFBD>todos y propiedades de objetos. Config file
|
||||
variables es una excepci<63>n de la sintaxis del signo de pesos.
|
||||
Tambi<EFBFBD>n puede ser referenciado entre signos de numeros, o con la
|
||||
variable especial $smarty.config.
|
||||
Las variable de Template que comiencen con signo de pesos.
|
||||
Pueden contener n<>meros, letras y guiones bajos, muy parecido a
|
||||
las <ulink url="&url.php-manual;language.variables">variables de PHP</ulink>.
|
||||
Usted tambi<62>n puede hacer referencia a arreglos que puden ser numericos o
|
||||
no-numericos. Tambi<62>n puede hacer referencia a m<>todos y propiedades de objetos.
|
||||
<link linkend="language.config.variables">Config file variables</link> es una
|
||||
excepci<EFBFBD>n de la sintaxis del signo de pesos.
|
||||
Tambi<62>n puede ser referenciado entre #signos de numeros#, o con la
|
||||
variable especial <link linkend="language.variables.smarty.config">$smarty.config</link>.
|
||||
</para>
|
||||
<example>
|
||||
<title>Variables</title>
|
||||
@@ -25,6 +27,7 @@
|
||||
{#foo#} <-- display the config file variable "foo"
|
||||
{$smarty.config.foo} <-- synonym for {#foo#}
|
||||
{$foo[bar]} <-- syntax only valid in a section loop, see {section}
|
||||
{assign var=foo value="baa"}{$foo} <-- displays "baa", see {assign}
|
||||
|
||||
Many other combinations are allowed
|
||||
|
||||
@@ -38,6 +41,10 @@ Many other combinations are allowed
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Vea tambi<62>n <link linkend="language.variables.smarty">$smarty reserved variables</link>
|
||||
y <link linkend="language.config.variables">Config Variables</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -38,12 +38,14 @@
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
capture es usado para recolectar toda la salida del template en una
|
||||
{capture} es usado para recolectar toda la salida del template en una
|
||||
variable en lugar de mostrarla.
|
||||
Cualquier contenido entre {capture name="foo"} y {/capture} es
|
||||
recoletado en una variable especificada y el atributo name. El
|
||||
contenido capturado puede ser usado en el template a partir de la
|
||||
variable especial $smarty.capture.foo en donde foo es el valor
|
||||
variable especial
|
||||
<link linkend="language.variables.smarty.capture">$smarty.capture.foo</link>
|
||||
en donde foo es el valor
|
||||
pasado para el atributo name. Si usted no pasa un atributo name,
|
||||
entonces ser<65> usado "default". Todos lo comandos {capture} deben
|
||||
estar entre {/capture}. Usted puede anidar(colocar uno dentro de
|
||||
@@ -61,9 +63,10 @@
|
||||
<caution>
|
||||
<para>
|
||||
Tenga cuidado cuando capture la salida del comando
|
||||
<command>insert</command>. Si tuviera activo el cache y tuviera
|
||||
comandos <command>insert</command> y usted espera que funcione
|
||||
con contenido de cache, no se capturara este contenido.
|
||||
<link linkend="language.function.insert">{insert}</link>.
|
||||
Si tuviera activo el <link linkend="caching">cache</link> y tuviera
|
||||
comandos <link linkend="language.function.insert">{insert}</link> y
|
||||
usted espera que funcione con contenido de cache, no se capturara este contenido.
|
||||
</para>
|
||||
</caution>
|
||||
<para>
|
||||
@@ -87,6 +90,15 @@
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
Ver Tambi<62>n
|
||||
<link linkend="language.variables.smarty.capture">$smarty.capture</link>,
|
||||
<link linkend="language.function.eval">{eval}</link>,
|
||||
<link linkend="language.function.fetch">{fetch}</link>,
|
||||
<link linkend="api.fetch">fetch()</link>
|
||||
y <link linkend="language.function.assign">{assign}</link>.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -64,19 +64,39 @@
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
Esta funci<63>n es usada para cargar las variables de un archivo de
|
||||
configuraci<EFBFBD>n dentro de un template.
|
||||
Esta funci<63>n es usada para cargar las <link
|
||||
linkend="language.config.variables">#variables#</link>
|
||||
de un archivo de configuraci<63>n dentro de un template.
|
||||
Vea <link linkend="config.files">Config Files</link> para mayor
|
||||
informaci<63>n.
|
||||
</para>
|
||||
<example>
|
||||
<title>funci<EFBFBD>n config_load</title>
|
||||
<title>Funci<EFBFBD>n {config_load}</title>
|
||||
<para>
|
||||
ejemplo.conf
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{config_load file="colors.conf"}
|
||||
#this is config file comment
|
||||
|
||||
# global variables
|
||||
pageTitle = "Main Menu"
|
||||
bodyBgColor = #000000
|
||||
tableBgColor = #000000
|
||||
rowBgColor = #00ff00
|
||||
|
||||
#customer variables section
|
||||
[Customer]
|
||||
pageTitle = "Customer Info"
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>y el template</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{config_load file="example.conf"}
|
||||
|
||||
<html>
|
||||
<title>{#pageTitle#}</title>
|
||||
<title>{#pageTitle#|default:"No title"}</title>
|
||||
<body bgcolor="{#bodyBgColor#}">
|
||||
<table border="{#tableBorderSize#}" bgcolor="{#tableBgColor#}">
|
||||
<tr bgcolor="{#rowBgColor#}">
|
||||
@@ -91,23 +111,24 @@
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Los archivos de configuraci<63>n pueden contener secciones tambi<62>n.
|
||||
Usted puede cargar variables de una secci<63>n adicionando el atributo
|
||||
<emphasis>section</emphasis>.
|
||||
Los <link linkend="config.files">archivos de configuraci<63>n</link>
|
||||
pueden contener secciones tambi<62>n. Usted puede cargar variables de
|
||||
una secci<63>n adicionando el atributo <emphasis>'section'</emphasis>.
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
<emphasis>Config file sections</emphasis> es la funci<63>n integrada
|
||||
de template <emphasis>section</emphasis> no tiene nada que ver
|
||||
uno con el otro, ellos justamente por casualidad tiene en com<6F>n el
|
||||
convensionalismo del nombre.
|
||||
de template <link
|
||||
linkend="language.function.section"><emphasis>{section}</emphasis></link>
|
||||
no tiene nada que ver uno con el otro, ellos justamente por casualidad
|
||||
tiene en com<6F>n el convensionalismo del nombre.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>Funci<EFBFBD>n config_load con section</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{config_load file="colors.conf" section="Customer"}
|
||||
{config_load file="ejemplo.conf" section="Customer"}
|
||||
|
||||
<html>
|
||||
<title>{#pageTitle#}</title>
|
||||
@@ -124,6 +145,13 @@
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Vea tambi<62>n <link linkend="config.files">Config files</link>,
|
||||
<link linkend="language.config.variables">Config variables</link>,
|
||||
<link linkend="variable.config.dir">$config_dir</link>,
|
||||
<link linkend="api.get.config.vars">get_config_vars()</link>
|
||||
y <link linkend="api.config.load">config_load()</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.foreach">
|
||||
<title>foreach,foreachelse</title>
|
||||
<title>{foreach},{foreachelse}</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -24,8 +24,7 @@
|
||||
<entry>array</entry>
|
||||
<entry>Si</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>El nombre de la matriz a la que usted estara pegando
|
||||
los elementos</entry>
|
||||
<entry>El nombre de la matriz a la que usted estara pegando los elementos</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>item</entry>
|
||||
@@ -54,8 +53,9 @@
|
||||
</informaltable>
|
||||
<para>
|
||||
Los ciclos(loop) <emphasis>foreach</emphasis> son una alternativa para loop
|
||||
<emphasis>section</emphasis>. <emphasis>foreach</emphasis> es usado para pegar
|
||||
cada elemento de una matriz asociativa simple.
|
||||
<link linkend="language.function.section"><emphasis>{section}</emphasis></link>.
|
||||
<emphasis>foreach</emphasis> es usado para pegar cada elemento de una
|
||||
<emphasis role="bold">matriz asociativa simple</emphasis>.
|
||||
La sintaxis para <emphasis>foreach</emphasis> es mucho mas simple que
|
||||
<emphasis>section</emphasis>, pero tiene una desventaja de que solo puede ser
|
||||
usada en una <20>nica matriz.
|
||||
@@ -73,64 +73,115 @@
|
||||
</para>
|
||||
<example>
|
||||
<title>foreach</title>
|
||||
<programlisting>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$arr = array( 1001,1002,1003);
|
||||
$smarty->assign('custid', $arr);
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* este ejemplo muestra todos los valores de la matriz $custid *}
|
||||
{foreach from=$custid item=curr_id}
|
||||
id: {$curr_id}<br>
|
||||
id: {$curr_id}<br />
|
||||
{/foreach}
|
||||
|
||||
SALIDA:
|
||||
|
||||
id: 1000<br>
|
||||
id: 1001<br>
|
||||
id: 1002<br></programlisting>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Esta es la salida del ejemplo de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
id: 1000<br />
|
||||
id: 1001<br />
|
||||
id: 1002<br />
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>foreach key</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
// La llave contiene la llave para cada valor del ciclo(loop)
|
||||
//asignacion fisica de esta manera:
|
||||
<?php
|
||||
$smarty->assign('contacts', array(
|
||||
array('phone' => '1',
|
||||
'fax' => '2',
|
||||
'cell' => '3'),
|
||||
array('phone' => '555-4444',
|
||||
'fax' => '555-3333',
|
||||
'cell' => '760-1234')
|
||||
));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<programlisting>
|
||||
{* La llave contiene la llave para cada valor del ciclo(loop)
|
||||
|
||||
asignacion fisica de esta manera:
|
||||
|
||||
$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
|
||||
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
|
||||
|
||||
*}
|
||||
|
||||
<![CDATA[
|
||||
{foreach name=outer item=contact from=$contacts}
|
||||
<hr />
|
||||
{foreach key=key item=item from=$contact}
|
||||
{$key}: {$item}<br>
|
||||
{$key}: {$item}<br />
|
||||
{/foreach}
|
||||
{/foreach}
|
||||
|
||||
SALIDA:
|
||||
|
||||
phone: 1<br>
|
||||
fax: 2<br>
|
||||
cell: 3<br>
|
||||
phone: 555-4444<br>
|
||||
fax: 555-3333<br>
|
||||
cell: 760-1234<br></programlisting>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Esta es la salida del ejemplo de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<hr />
|
||||
phone: 1<br />
|
||||
fax: 2<br />
|
||||
cell: 3<br />
|
||||
<hr />
|
||||
phone: 555-4444<br />
|
||||
fax: 555-3333<br />
|
||||
cell: 760-1234<br />
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<example>
|
||||
<title>Ejemplo de {foreach} - con base de datos (eg PEAR o ADODB)</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$sql = 'select contact_id, name, nick from contacts order by contact';
|
||||
$smarty->assign("contacts", $db->getAssoc($sql));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{foreach key=cid item=con from=$contacts}
|
||||
<a href="contact.php?contact_id={$cid}">{$con.name} - {$con.nick}</a><br />
|
||||
{/foreach}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
El ciclo(Loop) foreach tambi<62>n tiene sus propias variables para
|
||||
manipular las propiedades del foreach.
|
||||
Estas son indicadas as<61>: {$smarty.foreach.foreachname.varname} con
|
||||
foreachname siendo el nombre especificado del atributo
|
||||
Estas son indicadas as<61>:
|
||||
<link linkend="language.variables.smarty.loops">{$smarty.foreach.foreachname.varname}</link>
|
||||
con foreachname siendo el nombre especificado del atributo
|
||||
<emphasis>name</emphasis> del foreach.
|
||||
</para>
|
||||
|
||||
<para>Ver <link linkend="section.property.index">{section}</link>
|
||||
para ejemplos ide las propiedades bajo las cuales son identicos.
|
||||
</para>
|
||||
|
||||
<sect2 id="foreach.property.iteration">
|
||||
<title>iteration</title>
|
||||
<para>
|
||||
iteration es usado para mostrar la interaci<63>n actual del ciclo(loop).
|
||||
</para>
|
||||
<para>
|
||||
iteration siempre comienza en 1 incrementado uno a uno en cada interaci<63>nn.
|
||||
iteration siempre comienza en 1 incrementado en uno cada interaci<63>n.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
@@ -166,13 +217,14 @@ cell: 760-1234<br></programlisting>
|
||||
<emphasis>total</emphasis> Es usado para mostrar el n<>mero de interaciones
|
||||
del foreach. Este puede ser usado dentro o despu<70>s de el.
|
||||
</para>
|
||||
<para>
|
||||
Ver tambien <link linkend="language.function.section">{section}</link> y
|
||||
<link linkend="language.variables.smarty.loops">$smarty.foreach</link>.
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
|
@@ -3,10 +3,12 @@
|
||||
<sect1 id="language.function.if">
|
||||
<title>if,elseif,else</title>
|
||||
<para>
|
||||
Los comandos if del Smarty tiene mucho de la flexibilidad del comando
|
||||
if de php, con algunas adiciones para la herramienta de template.
|
||||
Los comandos <emphasis>{if}</emphasis> del Smarty tiene mucho de la
|
||||
flexibilidad del comando
|
||||
<ulink url="&url.php-manual;if"><command>if</command></ulink> de php,
|
||||
con algunas adiciones para la herramienta de template.
|
||||
Todo <emphasis>{if}</emphasis> debe tener su <emphasis>{/if}</emphasis>.
|
||||
<emphasis>{else}</emphasis> y <emphasis>{elseif}</emphasis> tambien son
|
||||
<emphasis>{else}</emphasis> y <emphasis>{elseif}</emphasis> tambi<EFBFBD>n son
|
||||
permitidos.
|
||||
Toda las condicionales de PHP son reconcidas, tal como
|
||||
<emphasis>||</emphasis>, <emphasis>or</emphasis>,
|
||||
@@ -79,6 +81,13 @@
|
||||
<entry>menor que o igual</entry>
|
||||
<entry><=</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>===</entry>
|
||||
<entry></entry>
|
||||
<entry>$a === 0</entry>
|
||||
<entry>Igual e indentico</entry>
|
||||
<entry>===</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>!</entry>
|
||||
<entry>not</entry>
|
||||
@@ -134,6 +143,7 @@
|
||||
<example>
|
||||
<title>sentencia if</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{if $name eq "Fred"}
|
||||
Welcome Sir.
|
||||
{elseif $name eq "Wilma"}
|
||||
@@ -160,7 +170,7 @@
|
||||
|
||||
|
||||
{* los parentesis son permitidos *}
|
||||
{if ( $amount < 0 or $amount > 1000 ) and $volume >= #minVolAmt#}
|
||||
{if ( $amount < 0 or $amount > 1000 ) and $volume >= #minVolAmt#}
|
||||
...
|
||||
{/if}
|
||||
|
||||
@@ -194,7 +204,9 @@
|
||||
{* 0=even, 1=even, 2=even, 3=odd, 4=odd, 5=odd, etc. *}
|
||||
{if $var is even by 3}
|
||||
...
|
||||
{/if}</programlisting>
|
||||
{/if}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.include.php">
|
||||
<title>include_php</title>
|
||||
<title>{include_php}</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -48,34 +48,27 @@
|
||||
<note>
|
||||
<title>Nota t<>cnica</title>
|
||||
<para>
|
||||
include_php es muy desaprovechado desde Smarty, usted puede
|
||||
{include_php} es muy desaprovechado desde Smarty, usted puede
|
||||
lograr la misma funcionalidad por medio de las funciones de
|
||||
costumbre del template.
|
||||
La unica raz<61>n para usar include_php es si usted en realidad tiene
|
||||
la necesidad de poner en cuarentna la funcion de php fuera del
|
||||
directorio de plugin y su codigo de la aplicaci<63>n.
|
||||
La unica raz<61>n para usar {include_php} es si usted en realidad tiene
|
||||
la necesidad de poner en cuarentena la funcion de php fuera del
|
||||
directorio de <link linkend="variable.plugins.dir">plugins</link> y
|
||||
su codigo de la aplicaci<63>n.
|
||||
Vea un <link linkend="tips.componentized.templates">ejemplo</link>
|
||||
de templates componentizados para detalles.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
Las etiquetas include_php son usadas para incluir un script PHP
|
||||
dentro de su template. Si la seguridad estuviera activada, entonces
|
||||
el script PHP debe estar localizado en la ruta $trusted_dir.
|
||||
Las etiquetas {include_php} son usadas para incluir un script PHP
|
||||
dentro de su template. <link linkend="variable.security">
|
||||
Si la seguridad estuviera activada</link>, entonces
|
||||
el script PHP debe estar localizado en la ruta <link
|
||||
linkend="variable.trusted.dir">$trusted_dir</link>.
|
||||
La etiqueta include_php debe tener el atributo "file", el cual
|
||||
contiene la ruta del archivo PHP a ser incluido, o el relativo
|
||||
al $trusted_dir, o una ruta absoluta.
|
||||
</para>
|
||||
<para>
|
||||
include_php es un buen medio para manipular templates con componentes,
|
||||
y mantiene el c<>digo PHP separado de los archivos del template.
|
||||
Vamos adecir que usted tenga un template que muestre la navegaci<63>n de
|
||||
su sitio, el cual es tirado autom<6F>ticamente a partir de una base de
|
||||
datos. Usted puede mantener su l<>gica de PHP que obtiene los datos en
|
||||
un directorio separado, e incluirla arriba del template. Ahora usted
|
||||
puede incluir este template en cualquier lugar sin preocuparse si la
|
||||
informaci<63>n de la base de datos fue obtenida por la aplicaci<63>n antes
|
||||
de usarla.
|
||||
al <link linkend="variable.trusted.dir">$trusted_dir</link>, o
|
||||
una ruta absoluta.
|
||||
</para>
|
||||
<para>
|
||||
Por default, los archivos son incluidos solo una vez a un cuando son
|
||||
@@ -87,19 +80,18 @@
|
||||
<para>
|
||||
Usted puede opcionalmente pasar el atributo <emphasis>assign</emphasis>,
|
||||
el cual especificara una variable del template la cual contendra toda la
|
||||
salida del <emphasis>include_php</emphasis> en vez de mostrarla.
|
||||
salida del <emphasis>{include_php}</emphasis> en vez de mostrarla.
|
||||
</para>
|
||||
<para>
|
||||
El objeto smarty esta disponible como $this dentro del script php que usted
|
||||
incluyo.
|
||||
</para>
|
||||
<example>
|
||||
<title>funcion include_php</title>
|
||||
<programlisting>
|
||||
load_nav.php
|
||||
-------------
|
||||
|
||||
<?php
|
||||
<title>funcion {include_php}</title>
|
||||
<para>load_nav.php</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
// carga variables de una base de datos mysql y def<65>ne esta para el template
|
||||
require_once("MySQL.class.php");
|
||||
@@ -107,18 +99,31 @@ load_nav.php
|
||||
$sql->query("select * from site_nav_sections order by name",SQL_ALL);
|
||||
$this->assign('sections',$sql->record);
|
||||
|
||||
?>
|
||||
|
||||
|
||||
index.tpl
|
||||
---------
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Donde index.tpl es:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* ruta absoluta o relativa del $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>
|
||||
<a href="{$curr_section.url}">{$curr_section.name}</a><br />
|
||||
{/foreach}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="language.function.include">{include}</link>,
|
||||
<link linkend="language.function.php">{php}</link>, <link
|
||||
linkend="language.function.capture">{capture}</link>, <link
|
||||
linkend="template.resources">Template Resources</link> y <link
|
||||
linkend="tips.componentized.templates">Componentized Templates</link>
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -45,25 +45,36 @@
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
Las etiquetas include son usadas para incluir otros templates en
|
||||
Las etiquetas {include} son usadas para incluir otros templates en
|
||||
el template actual. Cualquier variable disponible en el template
|
||||
actual, tambi<62>n esta disponible dentro del template incluido.
|
||||
La etiqueta include debe tener el atributo "file", el cual contiene
|
||||
La etiqueta {include} debe tener el atributo "file", el cual contiene
|
||||
la ruta del archivo a incluir.
|
||||
</para>
|
||||
<para>
|
||||
Usted puede opcionalmente pasar el atributo <emphasis>assign</emphasis>,
|
||||
Usted puede opcionalmente pasar el atributo <emphasis>'assign'</emphasis>,
|
||||
el cual especificara el nombre de una variable de template para el cual
|
||||
contendra toda la salida de <emphasis>include</emphasis> en vez de mostrarla.
|
||||
contendra toda la salida de {include} en vez de mostrarla.
|
||||
</para>
|
||||
<example>
|
||||
<title>funcion include</title>
|
||||
<title>funcion {include}</title>
|
||||
<programlisting>
|
||||
{include file="header.tpl"}
|
||||
<![CDATA[
|
||||
<html>
|
||||
<head>
|
||||
<title>{$title}</title>
|
||||
</head>
|
||||
<body>
|
||||
{include file="page_header.tpl"}
|
||||
|
||||
{* el cuerpo del template va aqui *}
|
||||
{include file="/$tpl_name.tpl"} <-- will replace $tpl_name with value
|
||||
|
||||
{include file="footer.tpl"}</programlisting>
|
||||
{include file="page_footer.tpl"}
|
||||
</body>
|
||||
</html>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Usted tambi<62>n puede pasar variables al template incluidas como
|
||||
@@ -73,21 +84,60 @@
|
||||
del template actual, en el caso en el que estas tengan el mismo nombre.
|
||||
</para>
|
||||
<example>
|
||||
<title>Funci<EFBFBD>n include pasando variables</title>
|
||||
<title>Funci<EFBFBD>n {include} pasando variables</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{include file="header.tpl" title="Main Menu" table_bgcolor="#c0c0c0"}
|
||||
|
||||
{* el cuerpo del template va aqui *}
|
||||
|
||||
{include file="footer.tpl" logo="http://my.domain.com/logo.gif"}</programlisting>
|
||||
{include file="footer.tpl" logo="http://my.example.com/logo.gif"}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>Donde header.tpl puede ser</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
<table border='1' width='100%' bgcolor='{$table_bgcolor|default:"#0000FF"}'>
|
||||
<tr><td>
|
||||
<h1>{$title}</h1>
|
||||
</td></tr>
|
||||
</table>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>{include} y asignacion de variables</title>
|
||||
<para>En este ejemplo asignan el contenido de nav.tpl en la variable $navbar,
|
||||
entonces la salida hasta arriba y hasta abajo de pagina.
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
<body>
|
||||
{include file="nav.tpl" assign="navbar"}
|
||||
{include file="header.tpl" title="Main Menu" table_bgcolor="#c0c0c0"}
|
||||
{$navbar}
|
||||
|
||||
{* el cuerpo del template va aqui *}
|
||||
|
||||
{include file="footer.tpl" logo="http://my.example.com/logo.gif"}
|
||||
{$navbar}
|
||||
</body>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
|
||||
|
||||
<para>
|
||||
Use la sintaxis de <link linkend="template.resources">template resources</link>
|
||||
para incluir archivos fuera del directorio $template_dir.
|
||||
para incluir archivos fuera del directorio
|
||||
<link linkend="variable.template.dir">$template_dir</link>.
|
||||
</para>
|
||||
<example>
|
||||
<title>Ejemplos de recursos para la funci<63>n include</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* ruta absoluta *}
|
||||
{include file="/usr/local/include/templates/header.tpl"}
|
||||
|
||||
@@ -98,7 +148,17 @@
|
||||
{include file="file:C:/www/pub/templates/header.tpl"}
|
||||
|
||||
{* incluir a partir del recurso de template denominado "db" *}
|
||||
{include file="db:header.tpl"}</programlisting>
|
||||
{include file="db:header.tpl"}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
ver tambi<62>n
|
||||
<link linkend="language.function.include.php">{include_php}</link>,
|
||||
<link linkend="language.function.php">{php}</link>,
|
||||
<link linkend="template.resources">Template Resources</link> y
|
||||
<link linkend="tips.componentized.templates">Componentized Templates</link>.
|
||||
</para>
|
||||
|
||||
</example>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -53,7 +53,8 @@
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
La etiqueta funciona parecido a las etiquetas include, excepto
|
||||
La etiqueta funciona parecido a las etiquetas <link
|
||||
linkend="language.function.include">{include}</link>, excepto
|
||||
que las etiquetas insert no van para el cache cuando
|
||||
<link linkend="caching">caching</link> esta activado.
|
||||
Esta sera executada a cada invocaci<63>n del template.
|
||||
@@ -63,15 +64,17 @@
|
||||
de la pagina. El banner puede contener cualquier mezcla de HTML, imagenes,
|
||||
flash, etc. As<41> nosotros no podemos usar una liga(link) estatica aqu<71>,
|
||||
y nosotros no queremos que este el contenido oculto con la pagina.
|
||||
Aqu<71> vemos la etiqueta insert: el template conoce los valores
|
||||
#banner_location_id# y #site_id# (obtenidos de un archivo de configuraci<63>n),
|
||||
Aqu<71> vemos la etiqueta {insert}: el template conoce los valores
|
||||
#banner_location_id# y #site_id# (obtenidos de un <link
|
||||
linkend="config.files">archivo de configuraci<63>n</link>),
|
||||
y necesita llamar una funci<63>n para obtener el contenido del banner.
|
||||
</para>
|
||||
<example>
|
||||
<title>funci<EFBFBD>n insert</title>
|
||||
<title>funci<EFBFBD>n {insert}</title>
|
||||
<programlisting>
|
||||
{* ejemplo de traer un banner *}
|
||||
{insert name="getBanner" lid=#banner_location_id# sid=#site_id#}</programlisting>
|
||||
{insert name="getBanner" lid=#banner_location_id# sid=#site_id#}
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
En este ejemplo, nosotros estamos usando el nombre "getBanner"
|
||||
@@ -90,17 +93,19 @@
|
||||
</para>
|
||||
<para>
|
||||
Si usted proporciona el atributo "assign", la salida de la etiqueta
|
||||
insert ser<65> dada a esta variable en vez de ser una salida en el template.
|
||||
Nota: definir la salida a una variable no es util cuando el cache esta
|
||||
activo.
|
||||
{insert} ser<65> dada a esta variable en vez de ser una salida en el template.
|
||||
Nota: definir la salida a una variable no es util cuando el <link
|
||||
linkend="variable.caching">cache</link> esta habilitado.
|
||||
</para>
|
||||
<para>
|
||||
Si usted proporciona el atributo "script", este script php ser<65>
|
||||
incluido (solo una vez) antes de la ejecuci<63>n de la funci<63>n insert.
|
||||
incluido (solo una vez) antes de la ejecuci<63>n de la funci<63>n {insert}.
|
||||
Este es el caso donde la funci<63>n insert no exista todavia, y el
|
||||
script php debe ser incluido antes para que pueda funcionar.
|
||||
La ruta puede ser absuluta o relativa a $trusted_dir.
|
||||
Cuando la seguridad esta activada, el script debe estar en $trusted_dir.
|
||||
La ruta puede ser absuluta o relativa a <link
|
||||
linkend="variable.trusted.dir">$trusted_dir</link>.
|
||||
Cuando <link linkend="variable.security">la seguridad esta activada</link>,
|
||||
el script debe estar en <link linkend="variable.trusted.dir">$trusted_dir</link>.
|
||||
</para>
|
||||
<para>
|
||||
El objeto Smarty es pasado como segundo argumento. De este modo
|
||||
|
@@ -1,17 +1,17 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.ldelim">
|
||||
<title>ldelim,rdelim</title>
|
||||
<title>{ldelim},{rdelim}</title>
|
||||
<para>
|
||||
ldelim y rdelim son usados para escapar delimitadores en el template,
|
||||
{ldelim} y {rdelim} son usados para
|
||||
<link linkend="language.escaping">escapar</link> delimitadores en el template,
|
||||
en nuestro caso "{" or "}". Usted puede usar solo
|
||||
<link linkend="language.function.literal">{literal}{/literal}</link> para
|
||||
escapar bloques de texto.
|
||||
Vea tambien <link linkend="language.variables.smarty.ldelim">{$smarty.ldelim}</link>
|
||||
y <link linkend="language.variables.smarty.rdelim">{$smarty.rdelim}</link>
|
||||
Vea tambien <link linkend="language.variables.smarty.ldelim">{$smarty.ldelim}</link>.
|
||||
</para>
|
||||
<example>
|
||||
<title>ldelim, rdelim</title>
|
||||
<title>{ldelim}, {rdelim}</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* Esto mostrara los delimitadores del template *}
|
||||
@@ -27,7 +27,31 @@
|
||||
{funcname} is how functions look in Smarty!
|
||||
]]>
|
||||
</screen>
|
||||
<para>Otros ejemplos con algunos javascript</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
<script language="JavaScript">
|
||||
function foo() {ldelim}
|
||||
... code ...
|
||||
{rdelim}
|
||||
</script>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
esta es la salida
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<script language="JavaScript">
|
||||
function foo() {
|
||||
.... code ...
|
||||
}
|
||||
</script>
|
||||
]]>
|
||||
</screen>
|
||||
|
||||
</example>
|
||||
<para>Vea tambi<62>n <link linkend="language.escaping">Escaping Smarty Parsing</link> </para>
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -4,22 +4,14 @@
|
||||
<title>literal</title>
|
||||
<para>
|
||||
Las etiquetas literal permiten que un block de datos sea tomado literalmente,
|
||||
no siendo interpretado por el smarty.
|
||||
Esto es util para cosas como secciones de javascript, en donde pueden
|
||||
haber llaves ("{}")
|
||||
y cosas asi que puedan confundir al interpretador del template.
|
||||
Cualquier cosa dentro las {literal}{/literal} no será
|
||||
interpretado, y sera mostrado tal como esta.
|
||||
no siendo interpretado por el smarty. Esto es generalmente utilizado alrededor
|
||||
de bloques javascript o stylesheet, en donde pueden haber sintaxis
|
||||
<link linkend="variable.left.delimiter">delimitadoras</link> que puedan
|
||||
interferir con el template.
|
||||
|
||||
|
||||
|
||||
Las etiquetas literal permiten que un bloque de datos sea tomado
|
||||
literalmente, este es tipicamente usado en ambiente javascript o
|
||||
stylesheet bloques donde las llaves interfieren con los delimitadores
|
||||
de sintaxis de Samrty.
|
||||
Cualquer cosa dentro de las etiquetas {literal}{/literal} no es
|
||||
interpretado, si no desplegado tal como esta. Si usted necesita en su
|
||||
template etiquetas empotradas en su bloque de literal, considere usar
|
||||
template etiquetas incrustadas en su bloque de literal, considere usar
|
||||
<link linkend="language.function.ldelim">{ldelim}{rdelim}</link> para
|
||||
escapar delimitadores individuales en lugar de eso.
|
||||
</para>
|
||||
@@ -47,6 +39,9 @@
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="language.escaping">Escaping Smarty Parsing</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -1,22 +1,40 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.php">
|
||||
<title>php</title>
|
||||
<title>{php}</title>
|
||||
<para>
|
||||
Las etiquetas php permiten que usted adicione c<>digo php directamente
|
||||
Las etiquetas {php} permiten a suetdd incrustar c<>digo php directamente
|
||||
en el template. No ser<65> escapado, no importando la definici<63>n de
|
||||
<link linkend="variable.php.handling">$php_handling</link>.
|
||||
Esto es solo para usuario avanzados y normalmente no es necesario.
|
||||
</para>
|
||||
<example>
|
||||
<title>Etiqueta php</title>
|
||||
<programlisting>
|
||||
<title>Etiqueta {php}</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
{php}
|
||||
// incluyendo un script php
|
||||
// directamente en el template.
|
||||
include("/path/to/display_weather.php");
|
||||
{/php}</programlisting>
|
||||
{/php}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<note>
|
||||
<title>Nota t<>cnica</title>
|
||||
<para>
|
||||
Para poder tener acceso a las variables de PHP puede ser necesario usar la palabra clave
|
||||
<ulink url="&url.php-manual;global">global</ulink> de PHP.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
ver Tambi<62>n
|
||||
<link linkend="variable.php.handling">$php_handling</link>,
|
||||
<link linkend="language.function.include.php">{include_php}</link>,
|
||||
<link linkend="language.function.include">{include}</link> y
|
||||
<link linkend="tips.componentized.templates">Componentized Templates</link>.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -28,11 +28,10 @@
|
||||
</row>
|
||||
<row>
|
||||
<entry>loop</entry>
|
||||
<entry>[$variable_name]</entry>
|
||||
<entry>mixed</entry>
|
||||
<entry>Si</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>El nombre de la variable para determinar el n<>mero de
|
||||
iteracciones</entry>
|
||||
<entry>El nombre de la variable para determinar el n<>mero de iteracciones</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>start</entry>
|
||||
@@ -76,7 +75,9 @@
|
||||
</informaltable>
|
||||
<para>
|
||||
Las section del template son usada para realizar un ciclo(loop) de
|
||||
un arreglo de datos. Todas las etiquetas <emphasis>section</emphasis>
|
||||
un <emphasis role="bold">arreglo de datos</emphasis>.
|
||||
(al agiual que un <link linkend="language.function.foreach">{foreach}</link>).
|
||||
Todas las etiquetas <emphasis>section</emphasis>
|
||||
deben tener su par <emphasis>/section</emphasis>. Los par<61>metros
|
||||
requeridos son <emphasis>name</emphasis> y <emphasis>loop</emphasis>.
|
||||
El nombre de la section puede ser el que usted quiera, formado por
|
||||
@@ -91,23 +92,89 @@
|
||||
</para>
|
||||
<example>
|
||||
<title>section</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$data = array(1000,1001,1002);
|
||||
$smarty->assign('custid',$data);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<programlisting>
|
||||
|
||||
{* este ejemplo muestra todos los valores del arreglo $custid *}
|
||||
<![CDATA[
|
||||
{* this example will print out all the values of the $custid array *}
|
||||
{section name=customer loop=$custid}
|
||||
id: {$custid[customer]}<br>
|
||||
id: {$custid[customer]}<br />
|
||||
{/section}
|
||||
|
||||
SALIDA:
|
||||
|
||||
id: 1000<br>
|
||||
id: 1001<br>
|
||||
id: 1002<br></programlisting>
|
||||
<hr />
|
||||
{* print out all the values of the $custid array reversed *}
|
||||
{section name=foo loop=$custid step=-1}
|
||||
{$custid[foo]}<br />
|
||||
{/section}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
The above example will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
id: 1000<br />
|
||||
id: 1001<br />
|
||||
id: 1002<br />
|
||||
<hr />
|
||||
id: 1002<br />
|
||||
id: 1001<br />
|
||||
id: 1000<br />
|
||||
]]>
|
||||
</screen>
|
||||
<para>
|
||||
Otro par de ejemplos sin un arreglo asignado.
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{section name=foo start=10 loop=20 step=2}
|
||||
{$smarty.section.foo.index}
|
||||
{/section}
|
||||
<hr />
|
||||
{section name=bar loop=21 max=6 step=-2}
|
||||
{$smarty.section.bar.index}
|
||||
{/section}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Esta es la salida del ejemplo de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
10 12 14 16 18
|
||||
<hr />
|
||||
20 18 16 14 12 10
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>loop(ciclo) de la variable section</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$id = array(1001,1002,1003);
|
||||
$smarty->assign('custid',$id);
|
||||
|
||||
$fullnames = array('John Smith','Jack Jones','Jane Munson');
|
||||
$smarty->assign('name',$fullnames);
|
||||
|
||||
$addr = array('253 N 45th', '417 Mulberry ln', '5605 apple st');
|
||||
$smarty->assign('address',$addr);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* la variable del loop solo determina el n<>mero de veces del ciclo.
|
||||
Usted puede accesar a cualquier variable del template dentro de la section.
|
||||
Este ejemplo asume que $custid, $name y $address son todas matrizes
|
||||
@@ -118,125 +185,237 @@ id: 1002<br></programlisting>
|
||||
address: {$address[customer]}<br>
|
||||
<p>
|
||||
{/section}
|
||||
|
||||
|
||||
SALIDA:
|
||||
|
||||
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>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
La salida del ajemplo de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<p>
|
||||
id: 1000<br />
|
||||
name: John Smith<br />
|
||||
address: 253 N 45th
|
||||
</p>
|
||||
<p>
|
||||
id: 1001<br />
|
||||
name: Jack Jones<br />
|
||||
address: 417 Mulberry ln
|
||||
</p>
|
||||
<p>
|
||||
id: 1002<br />
|
||||
name: Jane Munson<br />
|
||||
address: 5605 apple st
|
||||
</p>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>Nombres de section</title>
|
||||
<programlisting>
|
||||
{* El nombre de la section puede ser el que usted quiera,
|
||||
y es usado para referenciar los datos dentro de una section *}
|
||||
{section name=mydata loop=$custid}
|
||||
id: {$custid[mydata]}<br>
|
||||
name: {$name[mydata]}<br>
|
||||
address: {$address[mydata]}<br>
|
||||
<p>
|
||||
{/section}</programlisting>
|
||||
<![CDATA[
|
||||
{*
|
||||
El nombre de la section puede ser el que usted quiera,
|
||||
y es usado para referenciar los datos dentro de una section
|
||||
*}
|
||||
{section name=anything loop=$custid}
|
||||
<p>
|
||||
id: {$custid[anything]}<br />
|
||||
name: {$name[anything]}<br />
|
||||
address: {$address[anything]}
|
||||
</p>
|
||||
{/section}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>sections anidadas</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$id = array(1001,1002,1003);
|
||||
$smarty->assign('custid',$id);
|
||||
|
||||
$fullnames = array('John Smith','Jack Jones','Jane Munson');
|
||||
$smarty->assign('name',$fullnames);
|
||||
|
||||
$addr = array('253 N 45th', '417 Mulberry ln', '5605 apple st');
|
||||
$smarty->assign('address',$addr);
|
||||
|
||||
$types = array(
|
||||
array( 'home phone', 'cell phone', 'e-mail'),
|
||||
array( 'home phone', 'web'),
|
||||
array( 'cell phone')
|
||||
);
|
||||
$smarty->assign('contact_type', $types);
|
||||
|
||||
$info = array(
|
||||
array('555-555-5555', '666-555-5555', 'john@myexample.com'),
|
||||
array( '123-456-4', 'www.example.com'),
|
||||
array( '0457878')
|
||||
);
|
||||
$smarty->assign('contact_info', $info);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* Las sections pueden ser anidados tan profundamente como usted quiera.
|
||||
Con las sections anidadas, usted puede accesar a estructuras complejas,
|
||||
como una matriz multi-dimensional. En este ejemplo, $contact_type[customer]
|
||||
es una matriz de tipos de contacto para el cliente actual. *}
|
||||
{section name=customer loop=$custid}
|
||||
id: {$custid[customer]}<br>
|
||||
name: {$name[customer]}<br>
|
||||
address: {$address[customer]}<br>
|
||||
<hr>
|
||||
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>
|
||||
{$contact_type[customer][contact]}: {$contact_info[customer][contact]}<br />
|
||||
{/section}
|
||||
<p>
|
||||
{/section}
|
||||
|
||||
|
||||
SALIDA:
|
||||
|
||||
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>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
la salida del ejemplo de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<hr>
|
||||
id: 1000<br />
|
||||
name: John Smith<br />
|
||||
address: 253 N 45th<br />
|
||||
home phone: 555-555-5555<br />
|
||||
cell phone: 666-555-5555<br />
|
||||
e-mail: john@myexample.com<br />
|
||||
<hr>
|
||||
id: 1001<br />
|
||||
name: Jack Jones<br />
|
||||
address: 417 Mulberry ln<br />
|
||||
home phone: 123-456-4<br />
|
||||
web: www.example.com<br />
|
||||
<hr>
|
||||
id: 1002<br />
|
||||
name: Jane Munson<br />
|
||||
address: 5605 apple st<br />
|
||||
cell phone: 0457878<br />
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>sections y matrices asociativas</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$data = array(
|
||||
array('name' => 'John Smith', 'home' => '555-555-5555',
|
||||
'cell' => '666-555-5555', 'email' => 'john@myexample.com'),
|
||||
array('name' => 'Jack Jones', 'home' => '777-555-5555',
|
||||
'cell' => '888-555-5555', 'email' => 'jack@myexample.com'),
|
||||
array('name' => 'Jane Munson', 'home' => '000-555-5555',
|
||||
'cell' => '123456', 'email' => 'jane@myexample.com')
|
||||
);
|
||||
$smarty->assign('contacts',$data);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
||||
<programlisting>
|
||||
{* Este es un ejemplo que muestra los datos de una matriz asociativa
|
||||
dentro de una section *}
|
||||
<![CDATA[
|
||||
{*
|
||||
Este es un ejemplo que muestra los datos de una matriz asociativa
|
||||
dentro de una 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>
|
||||
<p>
|
||||
name: {$contacts[customer].name}<br />
|
||||
home: {$contacts[customer].home}<br />
|
||||
cell: {$contacts[customer].cell}<br />
|
||||
e-mail: {$contacts[customer].email}
|
||||
</p>
|
||||
{/section}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Esta es la salida del ejemplo de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<p>
|
||||
name: John Smith<br />
|
||||
home: 555-555-5555<br />
|
||||
cell: 666-555-5555<br />
|
||||
e-mail: john@myexample.com
|
||||
</p>
|
||||
<p>
|
||||
name: Jack Jones<br />
|
||||
home phone: 777-555-5555<br />
|
||||
cell phone: 888-555-5555<br />
|
||||
e-mail: jack@myexample.com
|
||||
</p>
|
||||
<p>
|
||||
name: Jane Munson<br />
|
||||
home phone: 000-555-5555<br />
|
||||
cell phone: 123456<br />
|
||||
e-mail: jane@myexample.com
|
||||
</p>
|
||||
]]>
|
||||
</screen>
|
||||
<para>Ejemplo usando una base de datos(eg usando Pear o Adodb)</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$sql = 'select id, name, home, cell, email from contacts';
|
||||
$smarty->assign('contacts',$db->getAll($sql) );
|
||||
|
||||
SALIDA:
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
||||
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>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{*
|
||||
salida de la base de datos, resultado en una tabla
|
||||
*}
|
||||
<table>
|
||||
<tr><th> </th><th>Name></th><th>Home</th><th>Cell</th><th>Email</th></tr>
|
||||
{section name=co loop=$contacts}
|
||||
<tr>
|
||||
<td><a href="view.php?id={$contacts[co].id}">view<a></td>
|
||||
<td>{$contacts[co].name}</td>
|
||||
<td>{$contacts[co].home}</td>
|
||||
<td>{$contacts[co].cell}</td>
|
||||
<td>{$contacts[co].email}</td>
|
||||
<tr>
|
||||
{/section}
|
||||
</table>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
|
||||
|
||||
<example>
|
||||
<title>sectionelse</title>
|
||||
<title>{sectionelse}</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* sectionelse se ejecutara si no hubieran valores en $custid *}
|
||||
{section name=customer loop=$custid}
|
||||
id: {$custid[customer]}<br>
|
||||
id: {$custid[customer]}<br />
|
||||
{sectionelse}
|
||||
there are no values in $custid.
|
||||
{/section}</programlisting>
|
||||
{/section}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Las sections tambi<62>n tiene sus propias variables que manipulan las
|
||||
propiedades de section. Estas son indicadas asi:
|
||||
{$smarty.section.sectionname.varname}
|
||||
<link linkend="language.variables.smarty.loops">{$smarty.section.sectionname.varname}</link>
|
||||
</para>
|
||||
<note>
|
||||
<para>
|
||||
@@ -258,55 +437,43 @@ e-mail: jane@mydomain.com<p></programlisting>
|
||||
<title>Nota Tecnica</title>
|
||||
<para>
|
||||
Si las propiedades de paso y comienzo del section son modificadas,
|
||||
entonces estas funcionan igual a las propiedades de iteration de la
|
||||
entonces estas funcionan igual a las propiedades de
|
||||
<link linkend="section.property.iteration">iteration</link> de la
|
||||
section, exepto que comienzan en 0 en vez de 1.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title> section propiedades del index</title>
|
||||
<title>{section} propiedades del index</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* FYI, $custid[customer.index] y $custid[customer] are identical in meaning *}
|
||||
|
||||
{section name=customer loop=$custid}
|
||||
{$smarty.section.customer.index} id: {$custid[customer]}<br>
|
||||
{$smarty.section.customer.index} id: {$custid[customer]}<br />
|
||||
{/section}
|
||||
|
||||
|
||||
SALIDA:
|
||||
|
||||
0 id: 1000<br>
|
||||
1 id: 1001<br>
|
||||
2 id: 1002<br>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
salida del ejemplo de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
0 id: 1000<br />
|
||||
1 id: 1001<br />
|
||||
2 id: 1002<br />
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="section.property.index.prev">
|
||||
<title>index_prev</title>
|
||||
<para>
|
||||
El index_prev es usado para mostrar el <20>ndice anterior del loop(ciclo).
|
||||
del primer loop(ciclo) esto es definido como -1.
|
||||
</para>
|
||||
<example>
|
||||
<title>section propiedades del 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}
|
||||
|
||||
|
||||
SALIDA:
|
||||
|
||||
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>
|
||||
@@ -315,28 +482,53 @@ e-mail: jane@mydomain.com<p></programlisting>
|
||||
la definici<63>n del atributo step que se a dado.)
|
||||
</para>
|
||||
<example>
|
||||
<title>section propiedades del 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}
|
||||
<title>{section} propiedades del index_next y index_prev</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$data = array(1001,1002,1003,1004,1005);
|
||||
$smarty->assign('custid',$data);
|
||||
|
||||
SALIDA:
|
||||
|
||||
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>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* FYI, $custid[cus.index] and $custid[cus] are identical in meaning *}
|
||||
|
||||
<table>
|
||||
<tr>
|
||||
<th>index</th><th>id</th>
|
||||
<th>index_prev</th><th>prev_id</th>
|
||||
<th>index_next</th><th>next_id</th>
|
||||
</tr>
|
||||
{section name=cus loop=$custid}
|
||||
<tr>
|
||||
<td>{$smarty.section.cus.index}</td><td>{$custid[cus]}</td>
|
||||
<td>{$smarty.section.cus.index_prev}</td><td>{$custid[cus.index_prev]}</td>
|
||||
<td>{$smarty.section.cus.index_next}</td><td>{$custid[cus.index_next]}</td>
|
||||
</tr>
|
||||
{/section}
|
||||
</table>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
la salida del ejemplo de arriba esta contenido en la siguiente tabla:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
index id index_prev prev_id index_next next_id
|
||||
0 1001 -1 1 1002
|
||||
1 1002 0 1001 2 1003
|
||||
2 1003 1 1002 3 1004
|
||||
3 1004 2 1003 4 1005
|
||||
4 1005 3 1004 5
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="section.property.iteration">
|
||||
<title>iteration</title>
|
||||
<para>
|
||||
@@ -345,125 +537,130 @@ e-mail: jane@mydomain.com<p></programlisting>
|
||||
<note>
|
||||
<para>
|
||||
Esto no es afectado por las propiedades del section start, step y max,
|
||||
distinto de las propriedades del index. Iteration tambi<62>n comineza con
|
||||
1 en vez de 0 como index. rownum es un alias de iteration, estas funcionan
|
||||
de manera identica.
|
||||
distinto de las propriedades del <link linkend="section.property.index">index</link>.
|
||||
Iteration tambi<62>n comineza con 1 en vez de 0 como index.
|
||||
<link linkend="section.property.rownum">rownum</link> es un alias de iteration,
|
||||
estas funcionan de manera identica.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>section propiedades de iteration</title>
|
||||
<title>{section} propiedades de iteration</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
// array of 3000 to 3015
|
||||
$id = range(3000,3015);
|
||||
$smarty->assign('custid',$id);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<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}
|
||||
<![CDATA[
|
||||
{section name=cu loop=$custid start=5 step=2}
|
||||
iteration={$smarty.section.cu.iteration}
|
||||
index={$smarty.section.cu.index}
|
||||
id={$custid[cu]}<br />
|
||||
{/section}
|
||||
|
||||
|
||||
SALIDA:
|
||||
|
||||
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>
|
||||
<para>
|
||||
salida del ejemplo de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
iteration=1 index=5 id=3005<br />
|
||||
iteration=2 index=7 id=3007<br />
|
||||
iteration=3 index=9 id=3009<br />
|
||||
iteration=4 index=11 id=3011<br />
|
||||
iteration=5 index=13 id=3013<br />
|
||||
iteration=6 index=15 id=3015<br />
|
||||
]]>
|
||||
</screen>
|
||||
<para>
|
||||
Este ejemplo utiliza la propiedad iteration para salida a una tabla
|
||||
bloqueando el encabezado para cada 5 renglones
|
||||
(utilice <link linkend="language.function.if">{if}</link> con el operador mod).
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
<table>
|
||||
{section name=co loop=$contacts}
|
||||
{if $smarty.section.co.iteration % 5 == 1}
|
||||
<tr><th> </th><th>Name></th><th>Home</th><th>Cell</th><th>Email</th></tr>
|
||||
{/if}
|
||||
<tr>
|
||||
<td><a href="view.php?id={$contacts[co].id}">view<a></td>
|
||||
<td>{$contacts[co].name}</td>
|
||||
<td>{$contacts[co].home}</td>
|
||||
<td>{$contacts[co].cell}</td>
|
||||
<td>{$contacts[co].email}</td>
|
||||
<tr>
|
||||
{/section}
|
||||
</table>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="section.property.first">
|
||||
<title>first</title>
|
||||
<para>
|
||||
first es definido como true se la iteraci<EFBFBD>n actual de la section es la primera.
|
||||
first es definido como true se la
|
||||
<link linkend="section.property.iteration">iteraci<EFBFBD>n</link>
|
||||
actual de la section es la primera.
|
||||
</para>
|
||||
<example>
|
||||
<title>section propiedades de 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}
|
||||
|
||||
|
||||
SALIDA:
|
||||
|
||||
<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 es definido como true si la iteraci<EFBFBD>n actual del section es la ultima.
|
||||
last es definido como true si la
|
||||
<link linkend="section.property.iteration">iteraci<EFBFBD>n</link>
|
||||
actual del section es la ultima.
|
||||
</para>
|
||||
<example>
|
||||
<title>section propiedades de last</title>
|
||||
<title>{section} propiedades first y last</title>
|
||||
<para>
|
||||
En este ciclo de ejemplo el arreglo $customer, en la salida es bloqueado
|
||||
el encabezado en la primera iteracion y en la ultima la salida es bloqueda
|
||||
para el pie de pagina.
|
||||
(Utilice la propiedad section <link linkend="section.property.total">total</link>)
|
||||
</para>
|
||||
<programlisting>
|
||||
{section name=customer loop=$custid}
|
||||
<![CDATA[
|
||||
{section name=customer loop=$customers}
|
||||
{if $smarty.section.customer.first}
|
||||
<table>
|
||||
<table>
|
||||
<tr><th>id</th><th>customer</th></tr>
|
||||
{/if}
|
||||
|
||||
<tr><td>{$smarty.section.customer.index} id:
|
||||
{$custid[customer]}</td></tr>
|
||||
<tr>
|
||||
<td>{$customers[customer].id}}</td>
|
||||
<td>{$customers[customer].name}</td>
|
||||
</tr>
|
||||
|
||||
{if $smarty.section.customer.last}
|
||||
</table>
|
||||
<tr><td></td><td>{$smarty.section.customer.total} customers</td></tr>
|
||||
</table>
|
||||
{/if}
|
||||
{/section}
|
||||
|
||||
|
||||
SALIDA:
|
||||
|
||||
<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 es usado para mostrar la interaci<63>n actual del loop(ciclo),
|
||||
comenzando con 1. Es un alias para iteration, estas funcionan de
|
||||
modo identico.
|
||||
comenzando con 1. Es un alias para
|
||||
<link linkend="section.property.iteration">iteration</link>, estas
|
||||
funcionan de modo identico.
|
||||
</para>
|
||||
<example>
|
||||
<title> section propiedades de rownum</title>
|
||||
<programlisting>
|
||||
{section name=customer loop=$custid}
|
||||
{$smarty.section.customer.rownum} id: {$custid[customer]}<br>
|
||||
{/section}
|
||||
|
||||
|
||||
SALIDA:
|
||||
|
||||
1 id: 1000<br>
|
||||
2 id: 1001<br>
|
||||
3 id: 1002<br>
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="section.property.loop">
|
||||
<title>loop</title>
|
||||
<para>
|
||||
@@ -471,24 +668,31 @@ e-mail: jane@mydomain.com<p></programlisting>
|
||||
loop(ciclo) de esta section. Esto puede ser usado dentro o fuera del section.
|
||||
</para>
|
||||
<example>
|
||||
<title>section propiedades de index</title>
|
||||
<title>{section} propiedades de index</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{section name=customer loop=$custid}
|
||||
{$smarty.section.customer.index} id: {$custid[customer]}<br>
|
||||
{$smarty.section.customer.index} id: {$custid[customer]}<br />
|
||||
{/section}
|
||||
|
||||
There were {$smarty.section.customer.loop} customers shown above.
|
||||
|
||||
SALIDA:
|
||||
|
||||
0 id: 1000<br>
|
||||
1 id: 1001<br>
|
||||
2 id: 1002<br>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
La salida del ejemplo de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
0 id: 1000<br />
|
||||
1 id: 1001<br />
|
||||
2 id: 1002<br />
|
||||
|
||||
There were 3 customers shown above.
|
||||
</programlisting>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="section.property.show">
|
||||
<title>show</title>
|
||||
<para>
|
||||
@@ -500,10 +704,13 @@ e-mail: jane@mydomain.com<p></programlisting>
|
||||
<example>
|
||||
<title>section atributos de show</title>
|
||||
<programlisting>
|
||||
{* $show_customer_info debe ser pasado de la aplicacion PHP,
|
||||
para regular cuando mostrar o no esta section shows*}
|
||||
<![CDATA[
|
||||
{*
|
||||
$show_customer_info debe ser pasado de la aplicacion PHP,
|
||||
para regular cuando mostrar o no esta section shows
|
||||
*}
|
||||
{section name=customer loop=$custid show=$show_customer_info}
|
||||
{$smarty.section.customer.rownum} id: {$custid[customer]}<br>
|
||||
{$smarty.section.customer.rownum} id: {$custid[customer]}<br />
|
||||
{/section}
|
||||
|
||||
{if $smarty.section.customer.show}
|
||||
@@ -511,18 +718,23 @@ e-mail: jane@mydomain.com<p></programlisting>
|
||||
{else}
|
||||
the section was not shown.
|
||||
{/if}
|
||||
|
||||
|
||||
SALIDA:
|
||||
|
||||
1 id: 1000<br>
|
||||
2 id: 1001<br>
|
||||
3 id: 1002<br>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
La salida del ejemplo de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
1 id: 1000<br />
|
||||
2 id: 1001<br />
|
||||
3 id: 1002<br />
|
||||
|
||||
the section was shown.
|
||||
</programlisting>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</sect2>
|
||||
|
||||
<sect2 id="section.property.total">
|
||||
<title>total</title>
|
||||
<para>
|
||||
@@ -530,25 +742,36 @@ e-mail: jane@mydomain.com<p></programlisting>
|
||||
section tendra. Este puede ser usado dentro o fuera del section.
|
||||
</para>
|
||||
<example>
|
||||
<title>section propiedades de total</title>
|
||||
<title>{section} propiedades de total</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{section name=customer loop=$custid step=2}
|
||||
{$smarty.section.customer.index} id: {$custid[customer]}<br>
|
||||
{$smarty.section.customer.index} id: {$custid[customer]}<br />
|
||||
{/section}
|
||||
|
||||
There were {$smarty.section.customer.total} customers shown above.
|
||||
|
||||
SALIDA:
|
||||
|
||||
0 id: 1000<br>
|
||||
2 id: 1001<br>
|
||||
4 id: 1002<br>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
The above example will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
0 id: 1000<br />
|
||||
2 id: 1002<br />
|
||||
4 id: 1004<br />
|
||||
|
||||
There were 3 customers shown above.
|
||||
</programlisting>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="language.function.foreach">{foreach}</link>
|
||||
y <link linkend="language.variables.smarty.loops">$smarty.section</link>.
|
||||
</para>
|
||||
</sect2>
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.strip">
|
||||
<title>strip</title>
|
||||
<title>{strip}</title>
|
||||
<para>
|
||||
Muchas veces el dise<73>ador de web tiene problemas con los espacios en
|
||||
blanco y retornos de carro que afectan la salida del HTML
|
||||
@@ -20,16 +20,16 @@
|
||||
<title>Nota T<>cnica</title>
|
||||
<para>
|
||||
{strip}{/strip} no afeta el contenido de las variables del template.
|
||||
Vea <link linkend="language.modifier.strip">strip modifier function</link>.
|
||||
Vea la funci<63>n <link linkend="language.modifier.strip">strip modifier</link>.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>strip tags</title>
|
||||
<title>{strip} tags</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* El siguiente c<>digo se ejecutara todo junto en una sola linea de salida *}
|
||||
{strip}
|
||||
<table border=0>
|
||||
<table border='0'>
|
||||
<tr>
|
||||
<td>
|
||||
<A HREF="{$url}">
|
||||
@@ -39,13 +39,16 @@
|
||||
</tr>
|
||||
</table>
|
||||
{/strip}
|
||||
|
||||
|
||||
SALIDA:
|
||||
|
||||
<table border=0><tr><td><A HREF="http://my.domain.com"><font color="red">This is a test</font></A></td></tr></table>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
salida del ejemplo de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<table border=0><tr><td><A HREF="http://w... snipped...</td></tr></table>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
Note que en el ejemplo de arriba, todas las lineas comienzan y termina
|
||||
@@ -54,6 +57,9 @@ SALIDA:
|
||||
o en el final de una linea, este estaria junto, y puede no ser el
|
||||
resultado deseado.
|
||||
</para>
|
||||
<para>
|
||||
Vea Tambi<62>n <link linkend="language.modifier.strip">strip modifier</link>
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -11,15 +11,18 @@
|
||||
<title>Combinando Modificadores</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
index.php:
|
||||
<?php
|
||||
$smarty = new Smarty;
|
||||
|
||||
$smarty->assign('articleTitle', 'Smokers are Productive, but Death Cuts Efficiency.');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
|
||||
index.tpl:
|
||||
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Donde el template es:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{$articleTitle}
|
||||
{$articleTitle|upper|spacify}
|
||||
{$articleTitle|lower|spacify|truncate}
|
||||
@@ -33,8 +36,8 @@ index.tpl:
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Smokers are Productive, but Death Cuts Efficiency.
|
||||
S M O K E R S A R E P R O D U C T I V E , B U T D E A T H C U T S E F F I C I E N C Y .
|
||||
s m o k e r s a r e p r o d u c t i v e , b u t d e a t h c u t s...
|
||||
S M O K E R S A R ....snip.... H C U T S E F F I C I E N C Y .
|
||||
s m o k e r s a r ....snip.... b u t d e a t h c u t s...
|
||||
s m o k e r s a r e p r o d u c t i v e , b u t . . .
|
||||
s m o k e r s a r e p. . .
|
||||
]]>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.assign">
|
||||
<title>assign</title>
|
||||
<title>{assign}</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -37,20 +37,86 @@
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
assign es usado para definir valores a las variables de template
|
||||
durante la ejecuci<63>n del template.
|
||||
{assign} es usado para definir valores a las variables de template
|
||||
<emphasis role="bold">durante la ejecuci<63>n</emphasis> del template.
|
||||
</para>
|
||||
<example>
|
||||
<title>assign</title>
|
||||
<title>{assign}</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{assign var="name" value="Bob"}
|
||||
|
||||
The value of $name is {$name}.
|
||||
|
||||
SALIDA:
|
||||
|
||||
The value of $name is Bob.</programlisting>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Salida del ejemplo de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
The value of $name is Bob.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
<example>
|
||||
<title>Accesando variables desde un script de PHP. {assign}</title>
|
||||
<para>
|
||||
Puedes accesar {assign} variables desde php usando
|
||||
<link linkend="api.get.template.vars">get_template_vars()</link>.
|
||||
sin embargo, las variables solo estan disponibles despues/durante
|
||||
la ejecuci<63>n del template como en el siguiente ejemplo
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* index.tpl *}
|
||||
{assign var="foo" value="Smarty"}
|
||||
]]>
|
||||
</programlisting>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
// this will output nothing as the template has not been executed
|
||||
echo $smarty->get_template_vars('foo');
|
||||
|
||||
// fetch the template to a dead variable
|
||||
$dead = $smarty->fetch('index.tpl');
|
||||
|
||||
// this will output 'smarty' as the template has been executed
|
||||
echo $smarty->get_template_vars('foo');
|
||||
|
||||
$smarty->assign('foo','Even smarter');
|
||||
|
||||
// this will output 'Even smarter'
|
||||
echo $smarty->get_template_vars('foo');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
La siguiente funci<63>n <emphasis>optionally</emphasis> tambi<62>n puede asignar variables al template.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<link linkend="language.function.capture">{capture}</link>,
|
||||
<link linkend="language.function.include">{include}</link>,
|
||||
<link linkend="language.function.include.php">{include_php}</link>,
|
||||
<link linkend="language.function.insert">{insert}</link>,
|
||||
<link linkend="language.function.counter">{counter}</link>,
|
||||
<link linkend="language.function.cycle">{cycle}</link>,
|
||||
<link linkend="language.function.eval">{eval}</link>,
|
||||
<link linkend="language.function.fetch">{fetch}</link>,
|
||||
<link linkend="language.function.math">{math}</link>,
|
||||
<link linkend="language.function.textformat">{textformat}</link>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="api.assign">assign()</link>
|
||||
y <link linkend="api.get.template.vars">get_template_vars()</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.counter">
|
||||
<title>counter</title>
|
||||
<title>{counter}</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -65,7 +65,7 @@
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
counter es usada para mostrar un conteo. counter va a depender del
|
||||
{counter} es usada para mostrar un conteo. {counter} va a depender del
|
||||
conteo en cada iteraci<63>n. Usted puede ajustar el n<>mero, el intervalo
|
||||
y la direcci<63>n del conteo, asi como determinar cuando mostrar o no el
|
||||
conteo. Usted puede tener varios contadores al mismo tiempo, dando un
|
||||
|
@@ -63,16 +63,23 @@
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>La variable del template que recibir<69> la salida</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>reset</entry>
|
||||
<entry>boolean</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>false</emphasis></entry>
|
||||
<entry>Este coloca al ciclo en el primer valor y no le permite avanzar</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
Cycle es usado para hacer un ciclo a través de un conjunto
|
||||
{Cycle} es usado para hacer un ciclo a trav<EFBFBD>s de un conjunto
|
||||
de valores. Esto hace mas f<>cil alternar entre dos o mas colores
|
||||
en una tabla, o ciclos a trav<61>z de una matriz de valores.
|
||||
</para>
|
||||
<para>
|
||||
Usted puede usar el cycle en mas de un conjunto de valores en su
|
||||
Usted puede usar el {cycle} en mas de un conjunto de valores en su
|
||||
template supliendo el atributo name. De cada uno de los conjuntos
|
||||
de valores.
|
||||
</para>
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.debug">
|
||||
<title>debug</title>
|
||||
<title>{debug}</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -23,7 +23,7 @@
|
||||
<entry>output</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>html</emphasis></entry>
|
||||
<entry><emphasis>javascript</emphasis></entry>
|
||||
<entry>Tipo de salida, html o javascript</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
@@ -38,6 +38,10 @@
|
||||
decir en uso. Usted puede ver todas las variables disponibles
|
||||
del template con scope.
|
||||
</para>
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="chapter.debugging.console">Debugging console</link>
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.eval">
|
||||
<title>eval</title>
|
||||
<title>{eval}</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -37,7 +37,7 @@
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
eval es usado para evaluar una variable como de template. Esto puede
|
||||
{eval} es usado para evaluar una variable como de template. Esto puede
|
||||
ser usado para cosas como incrustar tags(etiquetas)/variables del
|
||||
template dentro de las variables o tags(etiquetas)/variables dentro
|
||||
de las variables de un archivo de configuraci<63>n.
|
||||
@@ -60,26 +60,29 @@
|
||||
<para>
|
||||
Las variables evaluadas son compiladas en cada invocaci<63>n, las
|
||||
vesiones compiladas no son salvas. Sin embargo, si usted tiene
|
||||
activado el cache, la salida se va a fijar en la cache junto con
|
||||
el resto del template.
|
||||
activado el cache, la salida se va a fijar en la
|
||||
<link linkend="caching">cache</link> junto con el resto del template.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>eval</title>
|
||||
<title>{eval}</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
setup.conf
|
||||
----------
|
||||
|
||||
emphstart = <b>
|
||||
emphend = </b>
|
||||
emphstart = <strong>
|
||||
emphend = </strong>
|
||||
title = Welcome to {$company}'s home page!
|
||||
ErrorCity = You must supply a {#emphstart#}city{#emphend#}.
|
||||
ErrorState = You must supply a {#emphstart#}state{#emphend#}.
|
||||
|
||||
|
||||
index.tpl
|
||||
---------
|
||||
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Where index.tpl is:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{config_load file="setup.conf"}
|
||||
|
||||
{eval var=$foo}
|
||||
@@ -87,15 +90,20 @@ index.tpl
|
||||
{eval var=#ErrorCity#}
|
||||
{eval var=#ErrorState# assign="state_error"}
|
||||
{$state_error}
|
||||
|
||||
SALIDA:
|
||||
|
||||
This is the contents of foo.
|
||||
Welcome to Foobar Pub & Grill's home page!
|
||||
You must supply a <b>city</b>.
|
||||
You must supply a <b>state</b>.
|
||||
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
La salida del ejemplo de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
This is the contents of foo.
|
||||
Welcome to Foobar Pub & Grill's home page!
|
||||
You must supply a <strong>city</strong>.
|
||||
You must supply a <strong>state</strong>.
|
||||
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.fetch">
|
||||
<title>fetch</title>
|
||||
<title>{fetch}</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -37,7 +37,7 @@
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
fetch es usado para obtener archivos de sistema local, http o ftp, y
|
||||
{fetch} es usado para obtener archivos de sistema local, http o ftp, y
|
||||
mostrar el contenido. Si el nombre del archivo comienza con "http://",
|
||||
la p<>gina del web site sera traida y mostrada. Si el nombre del archivo
|
||||
comienza con "ftp://", el archivo ser<65> obtenido del servidor ftp y
|
||||
@@ -46,13 +46,13 @@
|
||||
</para>
|
||||
<para>
|
||||
Si usted indica el atributo especial "assign", la salida de la funci<63>n
|
||||
fetch se ira a una variable de template en vez de ser mostrada en el
|
||||
{fetch} se ira a una variable de template en vez de ser mostrada en el
|
||||
template. (nuevo en Smarty 1.5.0)
|
||||
</para>
|
||||
<note>
|
||||
<title>Nota T<>cnica</title>
|
||||
<para>
|
||||
Esto no soporta redirecionamento http, tenga la certeza de incluir
|
||||
Esto no soporta redirecionamento http, tenga la certeza de incluirlo
|
||||
en la barra el seguimiento para ir a buscar donde sea necesario.
|
||||
</para>
|
||||
</note>
|
||||
@@ -62,23 +62,23 @@
|
||||
Si tiene activada la seguridad en su template y usted estuviera
|
||||
recibiendo un archivo del sistema de archivos local, esto permitira
|
||||
que solo archivos de uno de los directorios estuviera definido como
|
||||
seguro. ($secure_dir)
|
||||
seguro. (<link linkend="variable.secure.dir">$secure_dir</link>)
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>fetch</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* Incluye algunos javascript en su template *}
|
||||
{fetch file="/export/httpd/www.domain.com/docs/navbar.js"}
|
||||
{* include some javascript in your template *}
|
||||
{fetch file="/export/httpd/www.example.com/docs/navbar.js"}
|
||||
|
||||
{* Incrusta algun texto sobre el template desde otro sitio web *}
|
||||
{* embed some weather text in your template from another web site *}
|
||||
{fetch file="http://www.myweather.com/68502/"}
|
||||
|
||||
{* Obtiene un archivo de noticias via ftp *}
|
||||
{fetch file="ftp://user:password@ftp.domain.com/path/to/currentheadlines.txt"}
|
||||
{* fetch a news headline file via ftp *}
|
||||
{fetch file="ftp://user:password@ftp.example.com/path/to/currentheadlines.txt"}
|
||||
|
||||
{* coloca el contenido en una variable de template *}
|
||||
{* assign the fetched contents to a template variable *}
|
||||
{fetch file="http://www.myweather.com/68502/" assign="weather"}
|
||||
{if $weather ne ""}
|
||||
<b>{$weather}</b>
|
||||
@@ -86,6 +86,11 @@
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="language.function.capture">{capture}</link>,
|
||||
<link linkend="language.function.eval">{eval}</link>
|
||||
y <link linkend="api.fetch">fetch()</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.html.checkboxes">
|
||||
<title>html_checkboxes</title>
|
||||
<title>{html_checkboxes}</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -41,7 +41,7 @@
|
||||
<entry>una matriz de salida para los botones checkbox</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>selected/checked</entry>
|
||||
<entry>selected</entry>
|
||||
<entry>string/array</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>empty</emphasis></entry>
|
||||
@@ -72,8 +72,9 @@
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
html_checkboxes es una funci<EFBFBD>n personalizada que crea un grupo
|
||||
de checkbox con datos privistos. Este cuida cuales items(s)
|
||||
{html_checkboxes} es una
|
||||
<link linkend="language.custom.functions">funci<EFBFBD>n personalizada</link>
|
||||
que crea un grupo de checkbox con datos privistos. Este cuida cuales items(s)
|
||||
estan selecionados por default. Los atributos requeridos son
|
||||
values y output, a menos que usted use options.
|
||||
Toda la salida es compatible con XHTML.
|
||||
@@ -84,65 +85,99 @@
|
||||
<input> creada.
|
||||
</para>
|
||||
<example>
|
||||
<title>html_checkboxes</title>
|
||||
<title>{html_checkboxes}</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
|
||||
$smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane Johnson','Charlie Brown'));
|
||||
$smarty->assign('cust_names', array(
|
||||
'Joe Schmoe',
|
||||
'Jack Smith',
|
||||
'Jane Johnson',
|
||||
'Charlie Brown')
|
||||
);
|
||||
$smarty->assign('customer_id', 1001);
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
where index.tpl is:
|
||||
donde el template es
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{html_checkboxes name="id" values=$cust_ids selected=$customer_id output=$cust_names separator="<br />"}
|
||||
]]
|
||||
{html_checkboxes name="id" values=$cust_ids output=$cust_names
|
||||
selected=$customer_id separator="<br />"}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
o donde el codigo es:
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('cust_checkboxes', array(
|
||||
1000 => 'Joe Schmoe',
|
||||
1001 => 'Jack Smith',
|
||||
1002 => 'Jane Johnson',
|
||||
1003 => 'Charlie Brown'));
|
||||
1003 => 'Charlie Brown')
|
||||
);
|
||||
$smarty->assign('customer_id', 1001);
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Donde index.tpl es:
|
||||
y el template es
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{html_checkboxes name="id" options=$cust_checkboxes selected=$customer_id separator="<br />"}
|
||||
{html_checkboxes name="id" options=$cust_checkboxes selected=$customer_id separator="<br />"}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Salida (los dos ejemplos):
|
||||
salida de ambos ejemplos:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<label><input type="checkbox" name="id[]" value="1000" />Joe Schmoe</label><br />
|
||||
<label><input type="checkbox" name="id[]" value="1001" checked="checked" />Jack Smith</label><br />
|
||||
<label><input type="checkbox" name="id[]" value="1001" checked="checked" />Jack Smith</label>
|
||||
<br />
|
||||
<label><input type="checkbox" name="id[]" value="1002" />Jane Johnson</label><br />
|
||||
<label><input type="checkbox" name="id[]" value="1003" />Charlie Brown</label><br />
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<example>
|
||||
<title>
|
||||
ejemplo de base de datos (eg PEAR o ADODB):
|
||||
</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$sql = 'select type_id, types from types order by type';
|
||||
$smarty->assign('types',$db->getAssoc($sql));
|
||||
|
||||
$sql = 'select * from contacts where contact_id=12';
|
||||
$smarty->assign('contact',$db->getRow($sql));
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{html_checkboxes name="type" options=$types selected=$contact.type_id separator="<br />"}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Vea tambi<62>n
|
||||
<link linkend="language.function.html.radios">{html_radios}</link>
|
||||
y <link linkend="language.function.html.options">{html_options}</link>
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.3 Maintainer: ramirez Status: ready -->
|
||||
<sect1 id="language.function.html.image">
|
||||
<title>html_image</title>
|
||||
<title>{html_image}</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -66,17 +66,19 @@
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
html_image es una funci<EFBFBD>n habitual que genera una etiqueta
|
||||
HTML para una imagen. La altura y lo largo son autom<6F>ticamente
|
||||
calculadas a partir del archivo de la imagen si ning<6E>n valor
|
||||
suplido.
|
||||
{html_image} es una
|
||||
<link linkend="language.custom.functions">funci<EFBFBD>n habitual</link>
|
||||
que genera una etiqueta HTML para una imagen. La altura y lo largo
|
||||
son autom<6F>ticamente calculadas a partir del archivo de la imagen si
|
||||
ning<6E>n valor suplido.
|
||||
</para>
|
||||
<para>
|
||||
basedir es el directorio base en el cual las rutas relativas de las
|
||||
imagenes estan basados. Si no lo proporciona, el document root del
|
||||
servidor (variable de ambiente DOCUMENT_ROOT) es usada como el
|
||||
directorio base. Si la seguridad esta habilitada, la ruta para la
|
||||
imagen debe estar dentro de un directorio seguro.
|
||||
servidor (<link linkend="language.variables.smarty">env</link> variable
|
||||
de ambiente DOCUMENT_ROOT) es usada como el
|
||||
directorio base. Si la <link linkend="variable.security">$security</link>
|
||||
esta habilitada, la ruta para la imagen debe estar dentro de un directorio seguro.
|
||||
</para>
|
||||
<para>
|
||||
<parameter>href</parameter> es el valor href a donde la imagen
|
||||
@@ -91,37 +93,26 @@
|
||||
<note>
|
||||
<title>Nota T<>cnica</title>
|
||||
<para>
|
||||
html_image requiere un acceso a disco para leer la imagen y
|
||||
calcular la altura y el largo. Si usted no usa cache en el
|
||||
template, generalmente es mejor evitar html_image y utilizar
|
||||
las etiquetas de imagem est<73>ticas para un optimo funcionamiento.
|
||||
{html_image} requiere un acceso a disco para leer la imagen y
|
||||
calcular la altura y el largo. Si usted no usa <link
|
||||
linkend="caching">cache</link> en el template,
|
||||
generalmente es mejor evitar {html_image} y utilizar
|
||||
las etiquetas de imagen est<73>ticas para un optimo funcionamiento.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>html_image example</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Donde index.tpl es:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
where index.tpl is:
|
||||
-------------------
|
||||
{html_image file="pumpkin.jpg"}
|
||||
{html_image file="/path/from/docroot/pumpkin.jpg"}
|
||||
{html_image file="../path/relative/to/currdir/pumpkin.jpg"}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
SALIDA (posible):
|
||||
la posible saldida puede ser:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.html.options">
|
||||
<title>html_options</title>
|
||||
<title>{html_options}</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -58,15 +58,16 @@
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
html_options es una funci<EFBFBD>n customizada que crea un grupo
|
||||
html option con los datos proporcionados. Este se encarga de
|
||||
cuidar cuales datos han sido selecionado por default.
|
||||
{html_options} es una
|
||||
<link linkend="language.custom.functions">funci<EFBFBD>n customizada</link>
|
||||
que crea un grupo html <select><option> con los datos proporcionados.
|
||||
Este se encarga de cuidar cuales datos han sido selecionado por default.
|
||||
Los atributos son valores y salidas, a menos que usted utilice
|
||||
options en lugar de eso.
|
||||
</para>
|
||||
<para>
|
||||
Si un valor es una matriz, este ser<65> tratado como un OPTGROUP html,
|
||||
y mostrara los grupos. La recursi<73>n es soportada por OPTGROUP.
|
||||
Si un valor es una matriz, este ser<65> tratado como un <optgroup> html,
|
||||
y mostrara los grupos. La recursi<73>n es soportada por <optgroup>.
|
||||
Todas las salidas son compatibles con XHTML.
|
||||
</para>
|
||||
<para>
|
||||
@@ -76,58 +77,116 @@
|
||||
De otra manera solo es generada la lista de opciones.
|
||||
</para>
|
||||
<para>
|
||||
Todos los parámetros que no estan en la lista de arriba son
|
||||
Todos los par<EFBFBD>metros que no estan en la lista de arriba son
|
||||
exibidos como name/value-pairs dentro de las etiquetas <select>.
|
||||
Estas son ignoradas si la opcion <emphasis>name</emphasis> no es dada.
|
||||
</para>
|
||||
<example>
|
||||
<title>html_options</title>
|
||||
<title>{html_options}</title>
|
||||
<para>
|
||||
<emphasis role="bold">Ejemplo 1:</emphasis>
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
|
||||
$smarty->assign('cust_names', array(
|
||||
'Joe Schmoe',
|
||||
'Jack Smith',
|
||||
'Jane Johnson',
|
||||
'Charlie Brown'));
|
||||
$smarty->assign('customer_id', 1001);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
donde el template es:
|
||||
</para>
|
||||
<programlisting>
|
||||
index.php:
|
||||
<![CDATA[
|
||||
<select name=customer_id>
|
||||
{html_options values=$cust_ids output=$cust_names selected=$customer_id}
|
||||
</select>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
<emphasis role="bold">Ejemplo 2:</emphasis>
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
|
||||
$smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane
|
||||
Johnson','Carlie Brown'));
|
||||
$smarty->assign('customer_id', 1001);
|
||||
$smarty->display('index.tpl');
|
||||
$smarty->assign('cust_options', array(
|
||||
1000 => 'Joe Schmoe',
|
||||
1001 => 'Jack Smith',
|
||||
1002 => 'Jane Johnson',
|
||||
1003 => 'Charlie Brown')
|
||||
);
|
||||
$smarty->assign('customer_id', 1001);
|
||||
|
||||
index.tpl:
|
||||
|
||||
<select name=customer_id>
|
||||
{html_options values=$cust_ids selected=$customer_id output=$cust_names}
|
||||
</select>
|
||||
|
||||
|
||||
index.php:
|
||||
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('cust_options', array(
|
||||
1001 => 'Joe Schmoe',
|
||||
1002 => 'Jack Smith',
|
||||
1003 => 'Jane Johnson',
|
||||
1004 => 'Charlie Brown'));
|
||||
$smarty->assign('customer_id', 1001);
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
<select name=customer_id>
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
donde el template es:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
<select name=customer_id>
|
||||
{html_options options=$cust_options selected=$customer_id}
|
||||
</select>
|
||||
</select>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Salida de ambos ejemplos de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<select name=customer_id>
|
||||
<option label="Joe Schmoe" value="1000">Joe Schmoe</option>
|
||||
<option label="Jack Smith" value="1001" selected="selected">Jack Smith</option>
|
||||
<option label="Jane Johnson" value="1002">Jane Johnson</option>
|
||||
<option label="Charlie Brown" value="1003">Charlie Brown</option>
|
||||
</select>
|
||||
|
||||
|
||||
SALIDA: (Ambos ejemplos)
|
||||
|
||||
<select name=customer_id>
|
||||
<option value="1000">Joe Schmoe</option>
|
||||
<option value="1001" selected="selected">Jack Smith</option>
|
||||
<option value="1002">Jane Johnson</option>
|
||||
<option value="1003">Charlie Brown</option>
|
||||
</select></programlisting>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<example>
|
||||
<title>{html_options} - Ejemplo con base de datos (eg PEAR o ADODB):</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$sql = 'select type_id, types from types order by type';
|
||||
$smarty->assign('types',$db->getAssoc($sql));
|
||||
|
||||
$sql = 'select contact_id, name, email, type_id
|
||||
from contacts where contact_id='.$contact_id;
|
||||
$smarty->assign('contact',$db->getRow($sql));
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Donde el template es:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
<select name="type_id">
|
||||
<option value='null'>-- none --</option>
|
||||
{html_options name="type" options=$types selected=$contact.type_id}
|
||||
</select>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
vea tambi<62>n
|
||||
<link linkend="language.function.html.checkboxes">{html_checkboxes}</link>
|
||||
y <link linkend="language.function.html.radios">{html_radios}</link>
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.html.radios">
|
||||
<title>html_radios</title>
|
||||
<title>{html_radios}</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -65,9 +65,10 @@
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
html_radios es una función customizada que crea grupos de
|
||||
botones de radio html con los datos proporcionados. Este esta
|
||||
atento para saber cual objeto esta selccionado por default.
|
||||
{html_radios} es una
|
||||
<link linkend="language.custom.functions">funci<EFBFBD>n customizada</link>
|
||||
que crea grupos de botones de radio html con los datos proporcionados.
|
||||
Este esta atento para saber cual objeto esta selccionado por default.
|
||||
Los atributos requeridos son valores y salidas, a menos que usted
|
||||
use option en lugar de eso. Toda salida es compatible con XHTML.
|
||||
</para>
|
||||
@@ -77,49 +78,105 @@
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>html_radios</title>
|
||||
<title>{html_radios} : Ejemplo 1</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
|
||||
$smarty->assign('cust_names', array(
|
||||
'Joe Schmoe',
|
||||
'Jack Smith',
|
||||
'Jane Johnson',
|
||||
'Charlie Brown')
|
||||
);
|
||||
$smarty->assign('customer_id', 1001);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Donde el template es:
|
||||
</para>
|
||||
<programlisting>
|
||||
index.php:
|
||||
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('cust_ids', array(1000,1001,1002,1003));
|
||||
$smarty->assign('cust_names', array('Joe Schmoe','Jack Smith','Jane
|
||||
Johnson','Charlie Brown'));
|
||||
$smarty->assign('customer_id', 1001);
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
|
||||
index.tpl:
|
||||
|
||||
{html_radios name="id" values=$cust_ids selected=$customer_id output=$cust_names separator="<br />"}
|
||||
|
||||
|
||||
index.php:
|
||||
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('cust_radios', array(
|
||||
1000 => 'Joe Schmoe',
|
||||
1001 => 'Jack Smith',
|
||||
1002 => 'Jane Johnson',
|
||||
1003 => 'Charlie Brown'));
|
||||
$smarty->assign('customer_id', 1001);
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
|
||||
index.tpl:
|
||||
|
||||
{html_radios name="id" options=$cust_radios selected=$customer_id separator="<br />"}
|
||||
|
||||
|
||||
SALIDA: (Ambos ejemplos)
|
||||
|
||||
<input type="radio" name="id" value="1000">Joe Schmoe<br />
|
||||
<input type="radio" name="id" value="1001" checked="checked">Jack Smith<br />
|
||||
<input type="radio" name="id" value="1002">Jane Johnson<br />
|
||||
<input type="radio" name="id" value="1003">Charlie Brown<br /></programlisting>
|
||||
<![CDATA[
|
||||
{html_radios name="id" values=$cust_ids output=$cust_names
|
||||
selected=$customer_id separator="<br />"}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<example>
|
||||
<title>{html_radios} : Ejemplo 2</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty->assign('cust_radios', array(
|
||||
1000 => 'Joe Schmoe',
|
||||
1001 => 'Jack Smith',
|
||||
1002 => 'Jane Johnson',
|
||||
1003 => 'Charlie Brown'));
|
||||
$smarty->assign('customer_id', 1001);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Donde index.tpl es:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{html_radios name="id" options=$cust_radios selected=$customer_id separator="<br />"}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Salida de ambos ejemplos:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<label for="id_1000">
|
||||
<input type="radio" name="id" value="1000" id="id_1000" />Joe
|
||||
Schmoe</label><br />
|
||||
<label for="id_1001"><input type="radio" name="id" value="1001" id="id_1001"
|
||||
checked="checked" />Jack
|
||||
Smith</label><br />
|
||||
<label for="id_1002"><input type="radio" name="id" value="1002" id="id_1002" />Jane
|
||||
Johnson</label><br />
|
||||
<label for="id_1003"><input type="radio" name="id" value="1003" id="id_1003" />Charlie
|
||||
Brown</label><br />
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<example>
|
||||
<title>{html_radios}- Ejemplo con base de Datos (eg PEAR o ADODB):</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$sql = 'select type_id, types from types order by type';
|
||||
$smarty->assign('types',$db->getAssoc($sql));
|
||||
|
||||
$sql = 'select contact_id, name, email, type_id
|
||||
from contacts where contact_id='.$contact_id;
|
||||
$smarty->assign('contact',$db->getRow($sql));
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
y el template:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{html_radios name="type" options=$types selected=$contact.type_id separator="<br />"}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
ver tambi<62>n
|
||||
<link linkend="language.function.html.checkboxes">{html_checkboxes}</link>
|
||||
y <link linkend="language.function.html.options">{html_options}</link>
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.html.select.date">
|
||||
<title>html_select_date</title>
|
||||
<title>{html_select_date}</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -86,8 +86,7 @@
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry>%02d</entry>
|
||||
<entry>Cual debe ser el formato de salida del dia
|
||||
dentro de (sprintf)</entry>
|
||||
<entry>Cual debe ser el formato de salida del dia dentro de (sprintf)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>day_value_format</entry>
|
||||
@@ -245,105 +244,102 @@
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
html_select_date es una funci<EFBFBD>n customizada que crea menus dropdowns
|
||||
de fechas para usted. Este puede mostrar algunos o todos por a<>o,
|
||||
mes y dia.
|
||||
{html_select_date} es una
|
||||
<link linkend="language.custom.functions">funci<EFBFBD>n customizada</link>
|
||||
que crea menus dropdowns de fechas para usted. Este puede mostrar
|
||||
algunos o todos por a<>o, mes y dia.
|
||||
</para>
|
||||
<example>
|
||||
<title>html_select_date</title>
|
||||
<title>{html_select_date}</title>
|
||||
<para>Codigo del Template</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{html_select_date}
|
||||
|
||||
|
||||
SALIDA:
|
||||
|
||||
<select name="Date_Month">
|
||||
<option value="1">January</option>
|
||||
<option value="2">February</option>
|
||||
<option value="3">March</option>
|
||||
<option value="4">April</option>
|
||||
<option value="5">May</option>
|
||||
<option value="6">June</option>
|
||||
<option value="7">July</option>
|
||||
<option value="8">August</option>
|
||||
<option value="9">September</option>
|
||||
<option value="10">October</option>
|
||||
<option value="11">November</option>
|
||||
<option value="12" selected>December</option>
|
||||
</select>
|
||||
<select name="Date_Day">
|
||||
<option value="1">01</option>
|
||||
<option value="2">02</option>
|
||||
<option value="3">03</option>
|
||||
<option value="4">04</option>
|
||||
<option value="5">05</option>
|
||||
<option value="6">06</option>
|
||||
<option value="7">07</option>
|
||||
<option value="8">08</option>
|
||||
<option value="9">09</option>
|
||||
<option value="10">10</option>
|
||||
<option value="11">11</option>
|
||||
<option value="12">12</option>
|
||||
<option value="13" selected>13</option>
|
||||
<option value="14">14</option>
|
||||
<option value="15">15</option>
|
||||
<option value="16">16</option>
|
||||
<option value="17">17</option>
|
||||
<option value="18">18</option>
|
||||
<option value="19">19</option>
|
||||
<option value="20">20</option>
|
||||
<option value="21">21</option>
|
||||
<option value="22">22</option>
|
||||
<option value="23">23</option>
|
||||
<option value="24">24</option>
|
||||
<option value="25">25</option>
|
||||
<option value="26">26</option>
|
||||
<option value="27">27</option>
|
||||
<option value="28">28</option>
|
||||
<option value="29">29</option>
|
||||
<option value="30">30</option>
|
||||
<option value="31">31</option>
|
||||
</select>
|
||||
<select name="Date_Year">
|
||||
<option value="2001" selected>2001</option>
|
||||
</select></programlisting>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Esta es la salida:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<select name="Date_Month">
|
||||
<option value="1">January</option>
|
||||
<option value="2">February</option>
|
||||
<option value="3">March</option>
|
||||
..... snipped .....
|
||||
<option value="10">October</option>
|
||||
<option value="11">November</option>
|
||||
<option value="12" selected="selected">December</option>
|
||||
</select>
|
||||
<select name="Date_Day">
|
||||
<option value="1">01</option>
|
||||
<option value="2">02</option>
|
||||
<option value="3">03</option>
|
||||
..... snipped .....
|
||||
<option value="11">11</option>
|
||||
<option value="12">12</option>
|
||||
<option value="13" selected="selected">13</option>
|
||||
<option value="14">14</option>
|
||||
<option value="15">15</option>
|
||||
..... snipped .....
|
||||
<option value="29">29</option>
|
||||
<option value="30">30</option>
|
||||
<option value="31">31</option>
|
||||
</select>
|
||||
<select name="Date_Year">
|
||||
<option value="2001" selected="selected">2001</option>
|
||||
</select>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
|
||||
<example>
|
||||
<title>html_select_date</title>
|
||||
<title>{html_select_date}</title>
|
||||
<programlisting>
|
||||
|
||||
{* el a<>o de comienzo y fin puede ser relativo al a<>o actual *}
|
||||
{html_select_date prefix="StartDate" time=$time start_year="-5" end_year="+1" display_days=false}
|
||||
|
||||
SALIDA: (El a<>o actual es 2000)
|
||||
|
||||
<select name="StartDateMonth">
|
||||
<option value="1">January</option>
|
||||
<option value="2">February</option>
|
||||
<option value="3">March</option>
|
||||
<option value="4">April</option>
|
||||
<option value="5">May</option>
|
||||
<option value="6">June</option>
|
||||
<option value="7">July</option>
|
||||
<option value="8">August</option>
|
||||
<option value="9">September</option>
|
||||
<option value="10">October</option>
|
||||
<option value="11">November</option>
|
||||
<option value="12" selected>December</option>
|
||||
</select>
|
||||
<select name="StartDateYear">
|
||||
<option value="1999">1995</option>
|
||||
<option value="1999">1996</option>
|
||||
<option value="1999">1997</option>
|
||||
<option value="1999">1998</option>
|
||||
<option value="1999">1999</option>
|
||||
<option value="2000" selected>2000</option>
|
||||
<option value="2001">2001</option>
|
||||
</select></programlisting>
|
||||
<![CDATA[
|
||||
{* el a<>o seleccionado puede ser relativo al a<>o actual *}
|
||||
{html_select_date prefix="StartDate" time=$time start_year="-5"
|
||||
end_year="+1" display_days=false}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
esta es la salida: (el a<>o actual es 2000)
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<select name="StartDateMonth">
|
||||
<option value="1">January</option>
|
||||
<option value="2">February</option>
|
||||
<option value="3">March</option>
|
||||
<option value="4">April</option>
|
||||
<option value="5">May</option>
|
||||
<option value="6">June</option>
|
||||
<option value="7">July</option>
|
||||
<option value="8">August</option>
|
||||
<option value="9">September</option>
|
||||
<option value="10">October</option>
|
||||
<option value="11">November</option>
|
||||
<option value="12" selected="selected">December</option>
|
||||
</select>
|
||||
<select name="StartDateYear">
|
||||
<option value="1995">1995</option>
|
||||
<option value="1996">1996</option>
|
||||
<option value="1997">1997</option>
|
||||
<option value="1998">1998</option>
|
||||
<option value="1999">1999</option>
|
||||
<option value="2000" selected="selected">2000</option>
|
||||
<option value="2001">2001</option>
|
||||
</select>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="language.function.html.select.time">{html_select_time}</link>,
|
||||
<link linkend="language.modifier.date.format">date_format</link>,
|
||||
<link linkend="language.variables.smarty.now">$smarty.now</link>
|
||||
y <link linkend="tips.dates">date tips</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.html.select.time">
|
||||
<title>html_select_time</title>
|
||||
<title>{html_select_time}</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -133,31 +133,27 @@
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
html_select_time es una funci<EFBFBD>n customizada
|
||||
que crea menus dropdowns de tiempo para usted.
|
||||
Esta puede mostrar algunos valores, o
|
||||
todo en hora, minuto, segundo y am/pm.
|
||||
{html_select_time} es una
|
||||
<link linkend="language.custom.functions">funci<EFBFBD>n customizada</link>
|
||||
que crea menus dropdowns de tiempo para usted. Esta puede mostrar
|
||||
algunos valores, o todo en hora, minuto, segundo y am/pm.
|
||||
</para>
|
||||
<para>
|
||||
Los atributos de time pueden tener diferentes
|
||||
formatos. el puede ser un unico timestamp o
|
||||
una cadena conteniendo Y-M-D. YYYY-MM-DD puede
|
||||
ser lo mas com<6F>n. exepto meses y dias con menos
|
||||
de dos digitos tambi<62>n son reconocidos;
|
||||
Si uno de los 3 valores (Y,M,D) es una cadena
|
||||
vacia, que segun el select-box no es pre-seleccionada
|
||||
del todo. este es especialmente usado con los
|
||||
atributos empty_teay-, -month- y -day-.
|
||||
Los atributos de time pueden tener diferentes formatos. Este puede ser
|
||||
un unico timestamp o una cadena conteniendo YYYYMMDDHHMMSS o una cadena
|
||||
parseda por php's <ulink url="&url.php-manual;strtotime">strtotime()</ulink>.
|
||||
</para>
|
||||
<example>
|
||||
<title>html_select_time</title>
|
||||
<title>{html_select_time}</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
template code:
|
||||
--------------
|
||||
{html_select_time use_24_hours=true}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Esta es la salidat:
|
||||
Esta es la salida:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -318,6 +314,12 @@
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n
|
||||
<link linkend="language.variables.smarty.now">$smarty.now</link>,
|
||||
<link linkend="language.function.html.select.date">{html_select_date}</link>
|
||||
y <link linkend="tips.dates">date tips</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.html.table">
|
||||
<title>html_table</title>
|
||||
<title>{html_table}</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -31,13 +31,12 @@
|
||||
<entry>integer</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>3</emphasis></entry>
|
||||
<entry>N<EFBFBD>mero de columnas para la tabla. Si el
|
||||
atributo cols esta vacio, los renglones seran determinados,
|
||||
entonces el numero de columnas sera calculado por el
|
||||
numero de renglones y el numero de elementos a mostrar
|
||||
para ser ajustado a las columnas de todos los
|
||||
elementos que seran mostrados, si ambos, renglones y
|
||||
columnas, son omitidos las columnas por default son 3.
|
||||
<entry>N<EFBFBD>mero de columnas para la tabla. Si el atributo cols esta vacio,
|
||||
los renglones seran determinados, entonces el numero de columnas
|
||||
sera calculado por el numero de renglones y el numero de elementos a
|
||||
mostrar para ser ajustado a las columnas de todos los elementos que seran
|
||||
mostrados, si ambos, renglones y columnas, son omitidos las columnas por
|
||||
default son 3.
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
@@ -45,12 +44,10 @@
|
||||
<entry>integer</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>empty</emphasis></entry>
|
||||
<entry> N<>mero de renglones en la tabla. Si el atributo
|
||||
rows es vacio, las columnas seran determinadas,
|
||||
entonces el numero de renglones sera calculado por el
|
||||
numero de columnas y el numero de elementos a mostrar
|
||||
para ser ajustado el numero de renglones al total de
|
||||
elementos a ser mostrados.
|
||||
<entry> N<>mero de renglones en la tabla. Si el atributo rows es vacio,
|
||||
las columnas seran determinadas, entonces el numero de renglones sera
|
||||
calculado por el numero de columnas y el numero de elementos a mostrar
|
||||
para ser ajustado el numero de renglones al total de elementos a ser mostrados.
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
@@ -58,12 +55,10 @@
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>cols</emphasis></entry>
|
||||
<entry> Direcci<63>n consecutiva de los elementos en el
|
||||
arreglo para ser representados.
|
||||
<emphasis>cols</emphasis> manera en que los
|
||||
elementos son mostrados columna por columna.
|
||||
<emphasis>rows</emphasis> manera en que los
|
||||
elementos son mostrados renglon por renglon.
|
||||
<entry> Direcci<63>n consecutiva de los elementos en el arreglo para ser representados.
|
||||
<emphasis>cols</emphasis> manera en que los elementos son mostrados columna
|
||||
por columna. <emphasis>rows</emphasis> manera en que los elementos son mostrados
|
||||
renglon por renglon.
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
@@ -101,10 +96,8 @@
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>right</emphasis></entry>
|
||||
<entry> direcci<63>n de una linea para ser representada.
|
||||
posibles valores:
|
||||
<emphasis>left</emphasis> (left-to-right),
|
||||
<emphasis>right</emphasis> (right-to-left)
|
||||
<entry> direcci<63>n de una linea para ser representada. posibles valores:
|
||||
<emphasis>left</emphasis> (left-to-right), <emphasis>right</emphasis> (right-to-left)
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
@@ -112,49 +105,55 @@
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>down</emphasis></entry>
|
||||
<entry>Direcci<EFBFBD>n de las columnas para ser representadas.
|
||||
posibles valores:
|
||||
<emphasis>down</emphasis> (top-to-bottom),
|
||||
<emphasis>up</emphasis> (bottom-to-top)
|
||||
<entry>Direcci<EFBFBD>n de las columnas para ser representadas. posibles valores:
|
||||
<emphasis>down</emphasis> (top-to-bottom), <emphasis>up</emphasis> (bottom-to-top)
|
||||
</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
<emphasis>html_table</emphasis> Es una funci<63>n customizada que
|
||||
transforma un arreglo de datos en una tabla HTML.
|
||||
El atributo <emphasis>cols</emphasis> determina el n<>mero de
|
||||
columnas que tendra la tabla.
|
||||
Los valores <emphasis>table_attr</emphasis>,
|
||||
<emphasis>tr_attr</emphasis> y <emphasis>td_attr</emphasis>
|
||||
determinan los atributos dados para las etiquetas tabla, tr y td.
|
||||
Si <emphasis>tr_attr</emphasis> o <emphasis>td_attr</emphasis>
|
||||
son arreglos, ellos entraran en un ciclo.
|
||||
<emphasis>trailpad</emphasis> y el valor depositado dentro de
|
||||
trailing cells en la ultima linea de la tabla si existe alguna
|
||||
presente.
|
||||
{html_table} Es una
|
||||
<link linkend="language.custom.functions">funci<EFBFBD>n customizada</link>
|
||||
que transforma un arreglo de datos en una tabla HTML. El atributo
|
||||
<emphasis>cols</emphasis> determina el n<>mero de columnas que tendra la tabla.
|
||||
Los valores <emphasis>table_attr</emphasis>, <emphasis>tr_attr</emphasis> y
|
||||
<emphasis>td_attr</emphasis> determinan los atributos dados para las etiquetas
|
||||
tabla, tr y td. Si <emphasis>tr_attr</emphasis> o <emphasis>td_attr</emphasis>
|
||||
son arreglos, ellos entraran en un ciclo. <emphasis>trailpad</emphasis> y el
|
||||
valor depositado dentro de trailing cells en la ultima linea de la tabla si existe
|
||||
alguna presente.
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>html_table</title>
|
||||
<programlisting>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
index.php:
|
||||
|
||||
php code:
|
||||
---------
|
||||
<?php
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('data',array(1,2,3,4,5,6,7,8,9));
|
||||
$smarty->assign('tr',array('bgcolor="#eeeeee"','bgcolor="#dddddd"'));
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
index.tpl:
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
template code:
|
||||
--------------
|
||||
{html_table loop=$data}
|
||||
{html_table loop=$data cols=4 table_attr='border="0"'}
|
||||
{html_table loop=$data cols=4 tr_attr=$tr}
|
||||
|
||||
SALIDA:
|
||||
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
La salida de ambos ejemplos:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<table border="1">
|
||||
<tr><td>1</td><td>2</td><td>3</td></tr>
|
||||
<tr><td>4</td><td>5</td><td>6</td></tr>
|
||||
@@ -170,9 +169,11 @@ SALIDA:
|
||||
<tr bgcolor="#dddddd"><td>5</td><td>6</td><td>7</td><td>8</td></tr>
|
||||
<tr bgcolor="#eeeeee"><td>9</td><td> </td><td> </td><td> </td></tr>
|
||||
</table>
|
||||
]]></programlisting>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.mailto">
|
||||
<title>mailto</title>
|
||||
<title>{mailto}</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -31,15 +31,16 @@
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>El texto para mostrar, el default es la
|
||||
direcci<63>n de correo (e-mail)</entry>
|
||||
<entry>El texto para mostrar, el default es la direcci<63>n de correo (e-mail)</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>encode</entry>
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>none</emphasis></entry>
|
||||
<entry>Como codificar el e-mail. Puede ser none, hex o javascript.
|
||||
<entry>Como codificar el e-mail. Puede ser
|
||||
<literal>none</literal>, <literal>hex</literal>,
|
||||
<literal>javascript</literal> o <literal>javascript_charcode</literal>.
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
@@ -96,7 +97,7 @@
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
mailto automatiza el proceso de creaci<63>n de links de correo
|
||||
{mailto} automatiza el proceso de creaci<63>n de links de correo
|
||||
electronico(e-mail) y opcionalmente los codifica.
|
||||
Codificar el correo electronico(e-mail) hace mas dif<69>cil que
|
||||
las web spiders tomen las direciones de nuestro sitio.
|
||||
@@ -109,30 +110,49 @@
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>mailto</title>
|
||||
<title>{mailto}</title>
|
||||
<programlisting>
|
||||
{mailto address="me@domain.com"}
|
||||
{mailto address="me@domain.com" text="send me some mail"}
|
||||
{mailto address="me@domain.com" encode="javascript"}
|
||||
{mailto address="me@domain.com" encode="hex"}
|
||||
{mailto address="me@domain.com" subject="Hello to you!"}
|
||||
{mailto address="me@domain.com" cc="you@domain.com,they@domain.com"}
|
||||
{mailto address="me@domain.com" extra='class="email"'}
|
||||
<![CDATA[
|
||||
{mailto address="me@example.com"}
|
||||
<a href="mailto:me@example.com" >me@example.com</a>
|
||||
|
||||
SALIDA:
|
||||
{mailto address="me@example.com" text="send me some mail"}
|
||||
<a href="mailto:me@example.com" >send me some mail</a>
|
||||
|
||||
<a href="mailto:me@domain.com" >me@domain.com</a>
|
||||
<a href="mailto:me@domain.com" >send me some mail</a>
|
||||
<script type="text/javascript" language="javascript">eval(unescape('%64%6f%63%75%6d%65%6e%74%2e%77%72%6
|
||||
9%74%65%28%27%3c%61%20%68%72%65%66%3d%22%6d%61%69%6c%74%6f%3a%6d%65%40%64%6f%6d%
|
||||
61%69%6e%2e%63%6f%6d%22%20%3e%6d%65%40%64%6f%6d%61%69%6e%2e%63%6f%6d%3c%2f%61%3e
|
||||
%27%29%3b'))</script>
|
||||
<a href="mailto:%6d%65@%64%6f%6d%61%69%6e.%63%6f%6d" >me@domain.com</a>
|
||||
<a href="mailto:me@domain.com?subject=Hello%20to%20you%21" >me@domain.com</a>
|
||||
<a href="mailto:me@domain.com?cc=you@domain.com%2Cthey@domain.com" >me@domain.com</a>
|
||||
<a href="mailto:me@domain.com" class="email">me@domain.com</a></programlisting>
|
||||
{mailto address="me@example.com" encode="javascript"}
|
||||
<script type="text/javascript" language="javascript">
|
||||
eval(unescape('%64%6f% ... snipped ...%61%3e%27%29%3b'))
|
||||
</script>
|
||||
|
||||
{mailto address="me@example.com" encode="hex"}
|
||||
<a href="mailto:%6d%65.. snipped..3%6f%6d">m&..snipped...#x6f;m</a>
|
||||
|
||||
{mailto address="me@example.com" subject="Hello to you!"}
|
||||
<a href="mailto:me@example.com?subject=Hello%20to%20you%21" >me@example.com</a>
|
||||
|
||||
{mailto address="me@example.com" cc="you@example.com,they@example.com"}
|
||||
<a href="mailto:me@example.com?cc=you@example.com%2Cthey@example.com" >me@example.com</a>
|
||||
|
||||
{mailto address="me@example.com" extra='class="email"'}
|
||||
<a href="mailto:me@example.com" class="email">me@example.com</a>
|
||||
|
||||
{mailto address="me@example.com" encode="javascript_charcode"}
|
||||
<script type="text/javascript" language="javascript">
|
||||
<!--
|
||||
{document.write(String.fromCharCode(60,97, ... snipped ....60,47,97,62))}
|
||||
//-->
|
||||
</script>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
ver tambi<62>n
|
||||
<link linkend="language.modifier.escape">escape</link>,
|
||||
<link linkend="tips.obfuscating.email">Obfuscating E-mail Addresses</link>
|
||||
y <link linkend="language.function.textformat">{textformat}</link>
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
|
@@ -58,7 +58,7 @@
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
math permite dise<73>ar ecuaciones matem<65>ticas dentro del template.
|
||||
{math} permite dise<73>ar ecuaciones matem<65>ticas dentro del template.
|
||||
Cualquier variable num<75>rica del template puede ser usada en
|
||||
ecuaciones, y el resultado es mostrado en lugar de la etiqueta.
|
||||
Las variables usadas en ecuaciones son pasadas como par<61>metros,
|
||||
@@ -76,55 +76,92 @@
|
||||
<note>
|
||||
<title>Nota T<>cnica</title>
|
||||
<para>
|
||||
math es una funci<63>n de muy alto rendimiento debido a que se
|
||||
puede usar con la funci<63>n eval() de PHP.
|
||||
Hacer las matem<65>ticas en PHP es mucho mas eficiente, asi en
|
||||
cualquier momento es posible hacer calculos matem<65>ticos en PHP
|
||||
asignarlos a una variable y lanzar los resultados al template.
|
||||
Def<EFBFBD>nitivamente evite llamadas repetitivas de funciones
|
||||
matem<EFBFBD>ticas, dentro de los ciclos section.
|
||||
{math} es una funci<63>n de muy alto rendimiento debido a que se puede
|
||||
usar con la funci<63>n <ulink url="&url.php-manual;eval">eval()</ulink>
|
||||
de PHP. Hacer las matem<65>ticas en PHP es mucho mas eficiente, asi en
|
||||
cualquier momento es posible hacer calculos matem<65>ticos en PHP asignarlos
|
||||
a una variable y lanzar los resultados al template. Def<65>nitivamente evite
|
||||
llamadas repetitivas de funciones matem<EFBFBD>ticas, dentro de los ciclos
|
||||
<link linkend="language.function.section">{section}</link>.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>math</title>
|
||||
<title>{math}</title>
|
||||
<para>
|
||||
<emphasis role="bold">Ejemplo a:</emphasis>
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* $height=4, $width=5 *}
|
||||
|
||||
{math equation="x + y" x=$height y=$width}
|
||||
|
||||
SALIDA:
|
||||
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Salida del ejemplo de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
9
|
||||
|
||||
|
||||
]]>
|
||||
</screen>
|
||||
<para>
|
||||
<emphasis role="bold">Ejemplo b:</emphasis>
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* $row_height = 10, $row_width = 20, #col_div# = 2, assigned in template *}
|
||||
|
||||
{math equation="height * width / division"
|
||||
height=$row_height
|
||||
width=$row_width
|
||||
division=#col_div#}
|
||||
|
||||
SALIDA:
|
||||
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Salida del ejemplo de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
100
|
||||
|
||||
|
||||
{* Usted puede usar parentesis *}
|
||||
]]>
|
||||
</screen>
|
||||
<para>
|
||||
<emphasis role="bold">Ejemplo c:</emphasis>
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* you can use parenthesis *}
|
||||
|
||||
{math equation="(( x + y ) / z )" x=2 y=10 z=2}
|
||||
|
||||
SALIDA:
|
||||
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Salida del ejemplo de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
6
|
||||
|
||||
|
||||
{* Usted puede asignar un par<61>metro de formato en sprintf *}
|
||||
]]>
|
||||
</screen>
|
||||
<para>
|
||||
<emphasis role="bold">Ejemplo d:</emphasis>
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* you can supply a format parameter in sprintf format *}
|
||||
|
||||
{math equation="x + y" x=4.4444 y=5.0000 format="%.2f"}
|
||||
|
||||
SALIDA:
|
||||
|
||||
9.44</programlisting>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Salida del ejemplo de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
9.44
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -1,28 +1,31 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.popup.init">
|
||||
<title>popup_init</title>
|
||||
<title>{popup_init}</title>
|
||||
<para>
|
||||
popup es una integraci<63>n de overLib, una biblioteca usada para
|
||||
ventanas popup. Esta es usada como contexto de infomaci<63>n sensitiva,
|
||||
como ventanas de ayuda o herramientas. popup_init debe ser usada una
|
||||
vez hasta arriba de cada pagina donde usted planea usar la funci<63>n
|
||||
<link linkend="language.function.popup">{popup}</link> es una integraci<63>n
|
||||
de <ulink url="&url.overLib;">overLib</ulink>, una biblioteca usada para
|
||||
ventanas popup. Esta es usada como contexto de infomaci<63>n sensitiva, como
|
||||
ventanas de ayuda o herramientas. {popup_init} debe ser usada una vez hasta
|
||||
arriba de cada pagina donde usted planea usar la funci<63>n
|
||||
<link linkend="language.function.popup">popup</link>.
|
||||
overLib fue escrita por Erik Bosrup, y la pagina esta localizada en
|
||||
http://www.bosrup.com/web/overlib/.
|
||||
<ulink url="&url.overLib;">overLib</ulink> fue escrita por Erik Bosrup, y la
|
||||
pagina esta localizada en <ulink url="&url.overLib;">&url.overLib;</ulink>.
|
||||
</para>
|
||||
<para>
|
||||
A partir da versión 2.1.2 de Smarty, overLib NO viene con la
|
||||
distribuci<63>n. Descargar el overLib, coloque el archivo overlib.js
|
||||
dentro de su document root e indique la ruta relativa en el par<61>metro
|
||||
"src" de popup_init.
|
||||
"src" de {popup_init}.
|
||||
</para>
|
||||
<example>
|
||||
<title>popup_init</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
<head>
|
||||
{* popup_init debe ser llamado una sola vez hasta arriba de la pagina *}
|
||||
{popup_init src="/javascripts/overlib.js"}
|
||||
</head>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
@@ -88,8 +88,7 @@
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>Def<EFBFBD>ne el color del texto para ser usado
|
||||
en el texto principal</entry>
|
||||
<entry>Def<EFBFBD>ne el color del texto para ser usado en el texto principal</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>captionfont</entry>
|
||||
@@ -263,8 +262,7 @@
|
||||
<entry>integer</entry>
|
||||
<entry>No</entry>
|
||||
<entry><emphasis>n/a</emphasis></entry>
|
||||
<entry>
|
||||
Indica al overLib desde que <20>ndice de la
|
||||
<entry> Indica al overLib desde que <20>ndice de la
|
||||
matriz ol_text debe leer el texto, localizada en overlib.js.
|
||||
Este par<61>metro puede ser usado en vez del texto
|
||||
</entry>
|
||||
@@ -396,22 +394,31 @@
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
popup es usado para crear ventanas popup con javascript.
|
||||
{popup} es usado para crear ventanas popup con javascript.
|
||||
<link linkend="language.function.popup.init">{popup_init}</link> DEBE ser
|
||||
llamado primero para poder trabajar.
|
||||
</para>
|
||||
<example>
|
||||
<title>popup</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* popup_init debe ser llamado una vez hasta arriba de la pagina *}
|
||||
{popup_init src="/javascripts/overlib.js"}
|
||||
|
||||
{* crea un link con una ventana popup que aparece cuando se pasa el mouse
|
||||
sobre este *}
|
||||
<A href="mypage.html" {popup text="This link takes you to my page!"}>mypage</A>
|
||||
{* crea un link con una ventana popup que aparece cuando se pasa el mouse sobre este *}
|
||||
<a href="mypage.html" {popup text="This link takes you to my page!"}>mypage</a>
|
||||
|
||||
{* usted puede usar html, links, etc en el texto del popup *}
|
||||
<A href="mypage.html" {popup sticky=true caption="mypage contents"
|
||||
text="<UL><LI>links<LI>pages<LI>images</UL>" snapx=10 snapy=10}>mypage</A></programlisting>
|
||||
<a href="mypage.html" {popup sticky=true caption="mypage contents"
|
||||
text="<ul><li>links</li><li>pages</li><li>images</li></ul>"
|
||||
snapx=10 snapy=10}>mypage</a>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="language.function.popup.init">{popup_init}</link>
|
||||
y <ulink url="&url.overLib;">overLib</ulink>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="language.function.textformat">
|
||||
<title>textformat</title>
|
||||
<title>{textformat}</title>
|
||||
<informaltable frame="all">
|
||||
<tgroup cols="5">
|
||||
<colspec colname="param" align="center" />
|
||||
@@ -81,19 +81,18 @@
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
textformat es una funci<EFBFBD>n de bloque usada para formatear texto.
|
||||
B<>sicamente limpa espacios y caracteres especiales, y formatea
|
||||
los p<>rrafos cortando el texto al final de la palabra y endentando
|
||||
lineas.
|
||||
{textformat} es una <link linkend="plugins.block.functions">funci<EFBFBD>n de bloque</link>
|
||||
usada para formatear texto. B<>sicamente limpa espacios y caracteres especiales, y
|
||||
formatea los p<>rrafos cortando el texto al final de la palabra y endentando lineas.
|
||||
</para>
|
||||
<para>
|
||||
Usted puede definir los par<61>metros expl<70>citamente, o usar un
|
||||
estilo pre-definido.
|
||||
Usted puede definir los par<61>metros expl<70>citamente, o usar un estilo pre-definido.
|
||||
Actualmente el <20>nico estilo disponible es "email".
|
||||
</para>
|
||||
<example>
|
||||
<title>textformat</title>
|
||||
<title>{textformat}</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{textformat wrap=40}
|
||||
|
||||
This is foo.
|
||||
@@ -115,7 +114,13 @@ bar foo bar foo foo.
|
||||
|
||||
{/textformat}
|
||||
|
||||
SALIDA:
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Salida del ajemplo de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
|
||||
This is foo. This is foo. This is foo.
|
||||
This is foo. This is foo. This is foo.
|
||||
@@ -126,8 +131,10 @@ bar foo bar foo foo. bar foo bar foo
|
||||
foo. bar foo bar foo foo. bar foo bar
|
||||
foo foo. bar foo bar foo foo. bar foo
|
||||
bar foo foo. bar foo bar foo foo.
|
||||
|
||||
|
||||
]]>
|
||||
</screen>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{textformat wrap=40 indent=4}
|
||||
|
||||
This is foo.
|
||||
@@ -149,7 +156,13 @@ bar foo bar foo foo.
|
||||
|
||||
{/textformat}
|
||||
|
||||
SALIDA:
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Salida del ejemplo de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
|
||||
This is foo. This is foo. This is
|
||||
foo. This is foo. This is foo. This
|
||||
@@ -162,7 +175,10 @@ SALIDA:
|
||||
bar foo foo. bar foo bar foo foo.
|
||||
bar foo bar foo foo. bar foo bar
|
||||
foo foo.
|
||||
|
||||
]]>
|
||||
</screen>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{textformat wrap=40 indent=4 indent_first=4}
|
||||
|
||||
This is foo.
|
||||
@@ -183,8 +199,13 @@ bar foo bar foo foo.
|
||||
bar foo bar foo foo.
|
||||
|
||||
{/textformat}
|
||||
|
||||
SALIDA:
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Salida del ejemplo de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
|
||||
This is foo. This is foo. This
|
||||
is foo. This is foo. This is foo.
|
||||
@@ -197,7 +218,10 @@ SALIDA:
|
||||
foo bar foo foo. bar foo bar foo
|
||||
foo. bar foo bar foo foo. bar foo
|
||||
bar foo foo.
|
||||
|
||||
]]>
|
||||
</screen>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{textformat style="email"}
|
||||
|
||||
This is foo.
|
||||
@@ -219,7 +243,13 @@ bar foo bar foo foo.
|
||||
|
||||
{/textformat}
|
||||
|
||||
SALIDA:
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Salida del ejemplo de arriba:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
|
||||
This is foo. This is foo. This is foo. This is foo. This is foo. This is
|
||||
foo.
|
||||
@@ -230,8 +260,15 @@ bar foo bar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo
|
||||
bar foo foo. bar foo bar foo foo. bar foo bar foo foo. bar foo bar foo
|
||||
foo.
|
||||
|
||||
</programlisting>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n
|
||||
<link linkend="language.function.strip">{strip}</link>
|
||||
y <link linkend="language.modifier.wordwrap">{wordwrap}</link>.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -14,14 +14,21 @@
|
||||
<title>Ejemplo de modificador</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* Uppercase the title *}
|
||||
<h2>{$title|upper}</h2>
|
||||
{* apply modifier to a variable *}
|
||||
{$title|upper}
|
||||
{* modifier with parameters *}
|
||||
{$title|truncate:40:"..."}
|
||||
|
||||
{* Truncate the topic to 40 characters use ... at the end *}
|
||||
Topic: {$topic|truncate:40:"..."}
|
||||
{* apply modifier to a function parameter *}
|
||||
{html_table loop=$myvar|upper}
|
||||
{* with parameters *}
|
||||
{html_table loop=$myvar|truncate:40:"..."}
|
||||
|
||||
{* format a literal string *}
|
||||
{"now"|date_format:"%Y/%m/%d"}
|
||||
{* apply modifier to literal string *}
|
||||
{"foobar"|upper}
|
||||
|
||||
{* using date_format to format the current date *}
|
||||
{$smarty.now|date_format:"%Y/%m/%d"}
|
||||
|
||||
{* apply modifier to a custom function *}
|
||||
{mailto|upper address="me@domain.dom"}
|
||||
@@ -59,10 +66,18 @@ Topic: {$topic|truncate:40:"..."}
|
||||
<link linkend="variable.security.settings">$security_settings['MODIFIER_FUNCS']
|
||||
</link>.
|
||||
</para>
|
||||
<para>
|
||||
Ver tambi<62>n
|
||||
<link linkend="api.register.modifier">register_modifier()</link>,
|
||||
<link linkend="api.register.function">register_function()</link>,
|
||||
<link linkend="plugins">Extending Smarty with plugins</link>
|
||||
y <link linkend="plugins.modifiers">modifiers</link>,
|
||||
</para>
|
||||
|
||||
|
||||
&designers.language-modifiers.language-modifier-capitalize;
|
||||
&designers.language-modifiers.language-modifier-count-characters;
|
||||
&designers.language-modifiers.language-modifier-cat;
|
||||
&designers.language-modifiers.language-modifier-count-characters;
|
||||
&designers.language-modifiers.language-modifier-count-paragraphs;
|
||||
&designers.language-modifiers.language-modifier-count-sentences;
|
||||
&designers.language-modifiers.language-modifier-count-words;
|
||||
|
@@ -40,15 +40,13 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', 'next x-men film, x3, delayed.');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Donde index.tpl es:
|
||||
Donde el template es:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
@@ -58,7 +56,7 @@ $smarty->display('index.tpl');
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Esta es la Salida:
|
||||
Esta es la salida:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -68,6 +66,9 @@ Next X-Men Film, X3, Delayed.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>Ver tambi<62>n <link linkend="language.modifier.lower">lower</link>
|
||||
<link linkend="language.modifier.upper">upper</link>
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -11,11 +11,11 @@
|
||||
<colspec colname="desc" />
|
||||
<thead>
|
||||
<row>
|
||||
<entry>Parameter Position</entry>
|
||||
<entry>Type</entry>
|
||||
<entry>Required</entry>
|
||||
<entry>Posiscion del Parametro</entry>
|
||||
<entry>Tipo</entry>
|
||||
<entry>Requerido</entry>
|
||||
<entry>cat</entry>
|
||||
<entry>Description</entry>
|
||||
<entry>Descripci<EFBFBD>n</entry>
|
||||
</row>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -37,14 +37,14 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$smarty = new Smarty;
|
||||
|
||||
$smarty->assign('articleTitle', "Psychics predict world didn't end");
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Donde index.tpl es:
|
||||
Donde el template es:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
@@ -52,7 +52,7 @@ $smarty->display('index.tpl');
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Salida:
|
||||
Esta es la salida:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
|
@@ -39,15 +39,13 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', 'Cold Wave Linked to Temperatures.');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Donde index.tpl es:
|
||||
Donde el template es:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
@@ -57,7 +55,7 @@ $smarty->display('index.tpl');
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Salida:
|
||||
esta es la salida:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -67,6 +65,12 @@ Cold Wave Linked to Temperatures.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
ver tambi<62>n
|
||||
<link linkend="language.modifier.count.words">count_words</link>,
|
||||
<link linkend="language.modifier.count.sentences">count_sentences</link> y
|
||||
<link linkend="language.modifier.count.paragraphs">count_paragraphs</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -10,15 +10,17 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', "War Dims Hope for Peace. Child's Death Ruins
|
||||
Couple's Holiday.\n\nMan is Fatally Slain. Death Causes Loneliness, Feeling of Isolation.");
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
$smarty->assign('articleTitle',
|
||||
"War Dims Hope for Peace. Child's Death Ruins Couple's Holiday.\n\n
|
||||
Man is Fatally Slain. Death Causes Loneliness, Feeling of Isolation."
|
||||
);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Donde index.tpl es:
|
||||
Donde el template es:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
@@ -27,7 +29,7 @@ $smarty->display('index.tpl');
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Esta es la Salida:
|
||||
Esta es la salida:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -38,6 +40,11 @@ Man is Fatally Slain. Death Causes Loneliness, Feeling of Isolation.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
ver tambi<62>n <link linkend="language.modifier.count.characters">count_characters</link>,
|
||||
<link linkend="language.modifier.count.sentences">count_sentences</link> y
|
||||
<link linkend="language.modifier.count.words">count_words</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -11,15 +11,16 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', 'Two Soviet Ships Collide - One Dies. Enraged Cow Injures Farmer with Axe.');
|
||||
$smarty->display('index.tpl');
|
||||
$smarty->assign('articleTitle',
|
||||
'Two Soviet Ships Collide - One Dies.
|
||||
Enraged Cow Injures Farmer with Axe.'
|
||||
);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Donde index.tpl es:
|
||||
Donde el template es:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
@@ -28,7 +29,7 @@ $smarty->display('index.tpl');
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Esta es la Salida:
|
||||
esta es la salida:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -37,6 +38,11 @@ Two Soviet Ships Collide - One Dies. Enraged Cow Injures Farmer with Axe.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
ver tambi<62>n <link linkend="language.modifier.count.characters">count_characters</link>,
|
||||
<link linkend="language.modifier.count.paragraphs">count_paragraphs</link> y
|
||||
<link linkend="language.modifier.count.words">count_words</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -11,15 +11,13 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Donde index.tpl es:
|
||||
Donde el template es:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
@@ -28,7 +26,7 @@ $smarty->display('index.tpl');
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Esta es la Salida:
|
||||
esta es la salida:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -37,6 +35,11 @@ Dealers Will Hear Car Talk at Noon.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
ver tambi<62>n <link linkend="language.modifier.count.characters">count_characters</link>,
|
||||
<link linkend="language.modifier.count.paragraphs">count_paragraphs</link> y
|
||||
<link linkend="language.modifier.count.sentences">count_sentences</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -39,11 +39,14 @@
|
||||
</informaltable>
|
||||
<para>
|
||||
Estos formatos de fecha y hora estan dentro del formato determinado
|
||||
strftime(). Las fechas pueden ser pasadas a Smarty como timestamps
|
||||
<ulink url="&url.php-manual;strftime">strftime()</ulink>.
|
||||
Las fechas pueden ser pasadas a Smarty como <ulink
|
||||
url="&url.php-manual;function.time">timestamps</ulink>
|
||||
unix, timestamps mysql, o como cualquier cadena compuesta de mes dia
|
||||
a<>o (pasada por strtotime). El dise<73>ador puede usar entonces date_format
|
||||
para tener un control completo del formateo de la fecha. Si la fecha
|
||||
pasada para date_format estuviera vacia y un segundo par<61>metro fuera
|
||||
a<>o (pasada por <ulink url="&url.php-manual;strtotime">strtotime()</ulink>).
|
||||
El dise<73>ador puede usar entonces date_format para tener un control completo
|
||||
del formateo de la fecha. Si la fecha pasada para
|
||||
<command>date_format</command> estuviera vacia y un segundo par<61>metro fuera
|
||||
pasado, este ser<65> usado como la fecha a formatear.
|
||||
</para>
|
||||
<example>
|
||||
@@ -52,34 +55,32 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('yesterday', strtotime('-1 day'));
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Donde index.tpl es:
|
||||
Where template is (uses <link linkend="language.variables.smarty.now">$smarty.now</link>):
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{$smarty.now|date_format}
|
||||
{$smarty.now|date_format:"%A, %B %e, %Y"}
|
||||
{$smarty.now|date_format:"%H:%M:%S"}
|
||||
{$smarty.now|date_format:"%D"}
|
||||
{$smarty.now|date_format:"%I:%M %p"}
|
||||
{$yesterday|date_format}
|
||||
{$yesterday|date_format:"%A, %B %e, %Y"}
|
||||
{$yesterday|date_format:"%H:%M:%S"}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Esta es la Salida:
|
||||
This will output:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Feb 6, 2001
|
||||
Tuesday, February 6, 2001
|
||||
14:33:00
|
||||
02/06/01
|
||||
02:33 pm
|
||||
Feb 5, 2001
|
||||
Monday, February 5, 2001
|
||||
14:33:00
|
||||
@@ -87,7 +88,7 @@ Monday, February 5, 2001
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
date_format especificadores de conversi<73>n:
|
||||
<command>date_format</command> especificadores de conversi<73>n:
|
||||
<itemizedlist>
|
||||
<listitem><para>
|
||||
%a - nombre del d<>a de la semana abreviado de acuerdo al local actual
|
||||
@@ -105,8 +106,7 @@ Monday, February 5, 2001
|
||||
%c - Representaci<63>n preferencial de la fecha y hora local actual
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
%C - a<>o con dos d<>gitos (o a<>o dividido por 100 y truncadopara un entero,
|
||||
intervalo de 00 a 99)
|
||||
%C - a<>o con dos d<>gitos (o a<>o dividido por 100 y truncadopara un entero, intervalo de 00 a 99)
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
%d - d<>a del mes como un n<>mero decimal (intervalo de 00 a 31)
|
||||
@@ -128,18 +128,16 @@ Monday, February 5, 2001
|
||||
%h - Lo mismo que %b
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
%H - Hora como un n<>mero decimal usando un rel<65>j de 24 horas (intervalo
|
||||
de 00 a 23)
|
||||
%H - Hora como un n<>mero decimal usando un rel<65>j de 24 horas (intervalo de 00 a 23)
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
%I - Hora como un n<>mero decimal usando un rel<65>j de 12 horas (intervalo
|
||||
de 01 a 12)
|
||||
%I - Hora como un n<>mero decimal usando un rel<65>j de 12 horas (intervalo de 01 a 12)
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
%j - D<>a del a<>o como um n<>mero decimal (intervalo de 001 a 366)
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
%k - Hora (rel<65>j de 24 horas) dig<69>tos <20>nicos que son precedidos por um
|
||||
%k - Hora (rel<65>j de 24 horas) dig<69>tos <20>nicos que son precedidos por un
|
||||
espacio en blanco (intervalo de 0 a 23)
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
@@ -175,8 +173,7 @@ Monday, February 5, 2001
|
||||
%T - Hora actual, igual a %H:%M:%S
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
%u - D<>a de la semana como un n<>mero decimal [1,7], representando
|
||||
con 1 el lunes
|
||||
%u - D<>a de la semana como un n<>mero decimal [1,7], representando con 1 el lunes
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
%U - N<>mero de la semana del a<>o actual como un n<>mero decimal,
|
||||
@@ -189,7 +186,7 @@ Monday, February 5, 2001
|
||||
domingo el primer dia de la semana.
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
%w - Día de la semana como decimal, siendo domingo 0
|
||||
%w - D<EFBFBD>a de la semana como decimal, siendo domingo 0
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
%W - N<>mero de la semana del a<>o actual como n<>mero decimal,
|
||||
@@ -217,14 +214,21 @@ Monday, February 5, 2001
|
||||
<note>
|
||||
<title>NOTA PARA PROGRAMADORES:</title>
|
||||
<para>
|
||||
date_format es escencialmente una envoltura para la funci<EFBFBD>n strftime()
|
||||
de PHP. Usted debera tener mas o menos especificadores de conversiones
|
||||
disponibles de acuerdo con la funci<63>n strftime() del sistema operacional
|
||||
en donde PHP fue compilado. Cheque en la pagina del manual de su sistema
|
||||
una lista completa de especificadores validos.
|
||||
<command>date_format</command> es escencialmente una envoltura para la
|
||||
funci<EFBFBD>n <ulink url="&url.php-manual;strftime">strftime()</ulink> de PHP.
|
||||
Usted debera tener mas o menos especificadores de conversiones disponibles
|
||||
de acuerdo con la funci<63>n <ulink url="&url.php-manual;strftime">strftime()</ulink>
|
||||
del sistema operacional en donde PHP fue compilado. Cheque en la pagina
|
||||
del manual de su sistema una lista completa de especificadores validos.
|
||||
</para>
|
||||
</note>
|
||||
</para>
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="language.variables.smarty.now">$smarty.now</link>,
|
||||
<ulink url="&url.php-manual;strftime">php function strftime()</ulink>,
|
||||
<link linkend="language.function.html.select.date">{html_select_date}</link>
|
||||
y <link linkend="tips.dates">date tips</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -41,15 +41,13 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', 'Dealers Will Hear Car Talk at Noon.');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Donde index.tpl es:
|
||||
Donde el template es:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
@@ -58,7 +56,7 @@ $smarty->display('index.tpl');
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Esta es la Salida:
|
||||
Esta es la salida:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -67,6 +65,10 @@ no title
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="tips.default.var.handling">Default Variable Handling</link>
|
||||
y <link linkend="tips.blank.var.handling">Blank Variable Handling</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -43,15 +43,15 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', "'Stiff Opposition Expected to Casketless Funeral Plan'");
|
||||
$smarty->display('index.tpl');
|
||||
$smarty->assign('articleTitle',
|
||||
"'Stiff Opposition Expected to Casketless Funeral Plan'"
|
||||
);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Donde index.tpl es:
|
||||
Donde el template es:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
@@ -65,7 +65,7 @@ $smarty->display('index.tpl');
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Esta es la Salida:
|
||||
esta es la salida:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -75,10 +75,14 @@ $smarty->display('index.tpl');
|
||||
'Stiff Opposition Expected to Casketless Funeral Plan'
|
||||
%27Stiff+Opposition+Expected+to+Casketless+Funeral+Plan%27
|
||||
\'Stiff Opposition Expected to Casketless Funeral Plan\'
|
||||
<a href="mailto:%62%6f%62%40%6d%65%2e%6e%65%74">bob@me.net</a>
|
||||
<a href="mailto:%62%6f%..snip..%65%74">bob..snip..et</a>
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="language.escaping">Escaping Smarty Parsing</link>
|
||||
y <link linkend="tips.obfuscating.email">Obfuscating E-mail Addresses</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -49,17 +49,18 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', 'NJ judge to rule on nude beach.
|
||||
$smarty->assign('articleTitle',
|
||||
'NJ judge to rule on nude beach.
|
||||
Sun or rain expected today, dark tonight.
|
||||
Statistics show that teen pregnancy drops off significantly after 25.');
|
||||
$smarty->display('index.tpl');
|
||||
Statistics show that teen pregnancy drops off significantly after 25.'
|
||||
);
|
||||
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Donde index.tpl es:
|
||||
Donde el template es:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
@@ -73,7 +74,7 @@ $smarty->display('index.tpl');
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Esta es la Salida:
|
||||
esta es la salida:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -95,6 +96,10 @@ Statistics show that teen pregnancy drops off significantly after 25.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
ver tambi<62>n <link linkend="language.modifier.strip">strip</link>
|
||||
y <link linkend="language.modifier.spacify">spacify</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -11,15 +11,13 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', 'Two Convicts Evade Noose, Jury Hung.');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Donde index.tpl es:
|
||||
Donde el template es:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
@@ -28,7 +26,7 @@ $smarty->display('index.tpl');
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Esta es la Salida:
|
||||
esta es la salida:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -37,6 +35,10 @@ two convicts evade noose, jury hung.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
ver tambi<62>n <link linkend="language.modifier.upper">upper</link> y
|
||||
<link linkend="language.modifier.capitalize">Capitalize</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -3,8 +3,9 @@
|
||||
<sect1 id="language.modifier.nl2br">
|
||||
<title>nl2br</title>
|
||||
<para>
|
||||
Todos los saltos de linea seran convertidos a etiquetas <br /> como
|
||||
datos de la variable. Esto equivale a la funci<63>n nl2br() de PHP.
|
||||
Todos los saltos de linea seran convertidos a etiquetas <br />
|
||||
como datos de la variable. Esto equivale a la funci<63>n
|
||||
<ulink url="&url.php-manual;nl2br">nl2br()</ulink> de PHP.
|
||||
</para>
|
||||
<example>
|
||||
<title>nl2br</title>
|
||||
@@ -12,15 +13,15 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', "Sun or rain expected\ntoday, dark tonight");
|
||||
$smarty->display('index.tpl');
|
||||
$smarty->assign('articleTitle',
|
||||
"Sun or rain expected\ntoday, dark tonight"
|
||||
);
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Donde index.tpl es:
|
||||
Donde el template es:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
@@ -28,7 +29,7 @@ $smarty->display('index.tpl');
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Esta es la Salida:
|
||||
esta debe ser la salida:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -36,6 +37,11 @@ Sun or rain expected<br />today, dark tonight
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="language.modifier.wordwrap">word_wrap</link>,
|
||||
<link linkend="language.modifier.count.paragraphs">count_paragraphs</link>
|
||||
y <link linkend="language.modifier.count.sentences">count_sentences</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -37,8 +37,8 @@
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
Localiza una expresi<73>n regular y la remplaza en la variable.
|
||||
Use la sintaxis para preg_replace() del manual de PHP.
|
||||
Localiza una expresi<73>n regular y la remplaza en la variable. Use la sintaxis para
|
||||
<ulink url="&url.php-manual;preg_replace">preg_replace()</ulink> del manual de PHP.
|
||||
</para>
|
||||
<example>
|
||||
<title>regex_replace</title>
|
||||
@@ -46,9 +46,7 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', "Infertility unlikely to\nbe passed on, experts say.");
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
@@ -65,7 +63,7 @@ $smarty->display('index.tpl');
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Esta es la Salida:
|
||||
Esta es la salida:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -75,6 +73,10 @@ Infertility unlikely to be passed on, experts say.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
Vea tambi<62>n <link linkend="language.modifier.replace">replace</link>
|
||||
y <link linkend="language.modifier.escape">escape</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -37,7 +37,8 @@
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
Una simple busqueda y substituir en la variable.
|
||||
Una simple busqueda y substituir en la variable. Esta es equivalente a la
|
||||
funci<63>n <ulink url="&url.php-manual;str_replace">str_replace()</ulink> de PHP.
|
||||
</para>
|
||||
<example>
|
||||
<title>replace</title>
|
||||
@@ -45,9 +46,7 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', "Child's Stool Great for Use in Garden.");
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
@@ -73,6 +72,11 @@ Child's Stool Great for Use in Garden.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
ver tambi<62>n <link linkend="language.modifier.regex.replace">regex_replace</link>
|
||||
y <link linkend="language.modifier.escape">escape</link>.
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -38,9 +38,9 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$smarty = new Smarty;
|
||||
|
||||
$smarty->assign('articleTitle', 'Something Went Wrong in Jet Crash, Experts Say.');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
@@ -65,6 +65,10 @@ S^^o^^m^^e^^t^^h^^i^^n^^g^^ ^^W^^e^^n^^t^^ ^^W^^r^^o^^n^^g^^ ^^i^^n^^ ^^J^^e^^t^
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="language.modifier.wordwrap">wordwrap</link>
|
||||
y <link linkend="language.modifier.nl2br">nl2br</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -31,7 +31,7 @@
|
||||
</informaltable>
|
||||
<para>
|
||||
Esta es una manera de formatear cadenas, como n<>meros decimales y otros.
|
||||
Use la sintaxis de sprintf para formatearlo.
|
||||
Use la sintaxis de <ulink url="&url.php-manual;sprintf">sprintf</ulink> para formatearlo.
|
||||
</para>
|
||||
<example>
|
||||
<title>string_format</title>
|
||||
@@ -39,9 +39,7 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('number', 23.5787446);
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
@@ -67,6 +65,9 @@ $smarty->display('index.tpl');
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="language.modifier.date.format">date_format</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -24,8 +24,7 @@
|
||||
<entry>bool</entry>
|
||||
<entry>No</entry>
|
||||
<entry>true</entry>
|
||||
<entry>Este determina cuando las etiquetas seran remplazadas por ' '
|
||||
o por ''</entry>
|
||||
<entry>Este determina cuando las etiquetas seran remplazadas por ' ' o por ''</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
@@ -39,10 +38,8 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', "Blind Woman Gets <font face=\"helvetica\">New
|
||||
Kidney</font> from Dad she Hasn't Seen in <b>years</b>.");
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
|
@@ -10,7 +10,7 @@
|
||||
<title>Nota</title>
|
||||
<para>
|
||||
Si usted quiere substituir bloques de texto de un template use la
|
||||
funci<63>n <link linkend="language.function.strip">strip</link>.
|
||||
funci<63>n <link linkend="language.function.strip">{strip}</link>.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
|
@@ -31,7 +31,8 @@
|
||||
<entry>string</entry>
|
||||
<entry>No</entry>
|
||||
<entry>...</entry>
|
||||
<entry>Este es el texto para adicionar si el truncamiento ocurre.</entry>
|
||||
<entry>Este es el texto para adicionar si el truncamiento ocurre. La
|
||||
longitud NO se incluye para la logitud del truncamiento</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>3</entry>
|
||||
@@ -42,6 +43,15 @@
|
||||
palabra(false), o un car<61>cter exacto(true).
|
||||
</entry>
|
||||
</row>
|
||||
<row>
|
||||
<entry>3</entry>
|
||||
<entry>boolean</entry>
|
||||
<entry>No</entry>
|
||||
<entry>false</entry>
|
||||
<entry>Este determina cuando ocurre el truncamiento al final de la cadena(false),
|
||||
o en el centro de la cadena(true). Nota cuando este es true,
|
||||
entonces la palabra limite es ignorada.</entry>
|
||||
</row>
|
||||
</tbody>
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
@@ -60,9 +70,7 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', 'Two Sisters Reunite after Eighteen Years at Checkout Counter.');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
|
@@ -11,9 +11,7 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', "If Strike isn't Settled Quickly it may Last a While.");
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
@@ -37,7 +35,12 @@ IF STRIKE ISN'T SETTLED QUICKLY IT MAY LAST A WHILE.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="language.modifier.lower">lower</link> y
|
||||
<link linkend="language.modifier.capitalize">capitalize</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
|
@@ -46,13 +46,13 @@
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
Este corta una cadena para un ancho de columna, el default es 80.
|
||||
Como segundo par<61>metro opcional, usted puede especificar la cadena
|
||||
que ser<65> usada para cortar el texto para la pr<70>xima linea (el default
|
||||
es un retorno de carro \n).
|
||||
Por default, wordwrap intentara cortar al final de una palabra. Si
|
||||
usted quisiera cortar un tama<6D>o exacto de cacarteres, pase al
|
||||
tercer par<61>metro, que es opcional, como true.
|
||||
Este <command>wordwrap</command> corta una cadena para un ancho de columna,
|
||||
el default es 80. Como segundo par<61>metro opcional, usted puede especificar
|
||||
la cadena que ser<65> usada para cortar el texto para la pr<70>xima linea (el default
|
||||
es un retorno de carro \n). Por default, (wordwrap) intentara cortar al final
|
||||
de una palabra. Si usted quisiera cortar un tama<6D>o exacto de cacarteres,
|
||||
pase al tercer par<61>metro, que es opcional, como true.
|
||||
Este es equivalente a la funci<63>n <ulink url="&url.php-manual;wordwrap">wordwrap()</ulink> de PHP.
|
||||
</para>
|
||||
<example>
|
||||
<title>wordwrap</title>
|
||||
@@ -60,9 +60,7 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('articleTitle', "Blind woman gets new kidney from dad she hasn't seen in years.");
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
@@ -109,6 +107,10 @@ years.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
<para>
|
||||
Ver Tambi<62>n <link linkend="language.modifier.nl2br">nl2br</link>
|
||||
y <link linkend="language.function.textformat">{textformat}</link>.
|
||||
</para>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -7,11 +7,14 @@
|
||||
depende de cual simbolo este prefijado(incluido dentro).
|
||||
</para>
|
||||
<para>
|
||||
Las variables de Smarty no pueden ser mostradas directamente o usadas
|
||||
como argumentos para atributos de funciones y modificadores, dentro de
|
||||
expresiones condicionales, etc. Para mostrar una variable, simplesmente
|
||||
coloque esta entre delimitadores siendo esta la <20>nica cosa entre ellos.
|
||||
Ejemplos:
|
||||
Las variables de Smarty no pueden ser mostradas directamente
|
||||
o usadas como argumentos para
|
||||
<link linkend="language.syntax.attributes">atributos</link>,
|
||||
<link linkend="language.syntax.functions">funciones</link> y
|
||||
<link linkend="language.modifiers">modificadores</link>, dentro
|
||||
de expresiones condicionales, etc. Para mostrar una variable,
|
||||
simplesmente coloque esta entre delimitadores siendo esta la <20>nica
|
||||
cosa entre ellos. Ejemplos:
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{$Name}
|
||||
|
@@ -3,34 +3,57 @@
|
||||
<sect1 id="language.assigned.variables">
|
||||
<title>Variables definidas desde PHP</title>
|
||||
<para>
|
||||
Las variables que son definidas desde PHP son referenciadas precedendo
|
||||
estas con una se<73>al de cifrado <literal>$</literal>. Las variables
|
||||
definidas dentro del template como una funci<63>n
|
||||
Las variables que son <link linkend="api.assign">asignadas</link> desde PHP
|
||||
son referenciadas precedidas estas con una se<73>al de cifrado <literal>$</literal>.
|
||||
Las variables definidas dentro del template como una funci<63>n
|
||||
<link linkend="language.function.assign">assign</link> tambi<62>n son
|
||||
mostradas de esta manera.
|
||||
</para>
|
||||
<example>
|
||||
|
||||
<title>variables definidas</title>
|
||||
<programlisting>
|
||||
<para> php script</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
Hello {$firstname}, glad to see you could make it.
|
||||
<br />
|
||||
Your last login was on {$lastLoginDate}.
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
|
||||
$smarty->assign('firstname', 'Doug');
|
||||
$smarty->assign('lastname', 'Evans');
|
||||
$smarty->assign('meetingPlace', 'New York');
|
||||
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
This will output:
|
||||
Donde el contenido de index.tpl es:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
Hello {$firstname} {$lastname}, glad to see you can make it.
|
||||
<br />
|
||||
{* this will not work as $vars are case sensitive *}
|
||||
This weeks meeting is in {$meetingplace}.
|
||||
{* this will work *}
|
||||
This weeks meeting is in {$meetingPlace}.
|
||||
]]>
|
||||
</programlisting>
|
||||
|
||||
<para>
|
||||
esta es la salida:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
Hello Doug, glad to see you could make it.
|
||||
Hello Doug Evans, glad to see you can make it.
|
||||
<br />
|
||||
Your last login was on January 11th, 2001.
|
||||
This weeks meeting is in .
|
||||
This weeks meeting is in New York.
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
<sect2 id="language.variables.assoc.arrays">
|
||||
<title>Arreglos asociativos</title>
|
||||
<para>
|
||||
@@ -43,18 +66,19 @@ Your last login was on January 11th, 2001.
|
||||
<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')));
|
||||
'cell' => '555-111-1234')
|
||||
)
|
||||
);
|
||||
$smarty->display('index.tpl');
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
where the content of index.tpl is:
|
||||
Donde el contenido de index.tpl es:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
@@ -66,7 +90,7 @@ $smarty->display('index.tpl');
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
this will output:
|
||||
esta es la salida:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -89,20 +113,18 @@ zaphod@slartibartfast.com<br />
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
$smarty = new Smarty;
|
||||
$smarty->assign('Contacts',
|
||||
array('555-222-9876',
|
||||
$smarty->assign('Contacts', array(
|
||||
'555-222-9876',
|
||||
'zaphod@slartibartfast.com',
|
||||
array('555-444-3333',
|
||||
'555-111-1234')));
|
||||
'555-111-1234')
|
||||
));
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
where index.tpl is:
|
||||
Donde index.tpl es:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
@@ -114,7 +136,7 @@ $smarty->display('index.tpl');
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
This will output:
|
||||
esta es la salida:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -127,14 +149,14 @@ zaphod@slartibartfast.com<br />
|
||||
</example>
|
||||
</sect2>
|
||||
<sect2 id="language.variables.objects">
|
||||
<title>Objetos</title>
|
||||
<title>Objects</title>
|
||||
<para>
|
||||
Las propiedades de los objetos definidos desde PHP pueden ser
|
||||
referenciados especificando el nombre de la propiedad despu<EFBFBD>;s
|
||||
del simbolo '->'.
|
||||
Las propiedades de los <link linkend="advanced.features.objects">objetos</link>
|
||||
definidos desde PHP pueden ser referenciados especificando el nombre de la propiedad
|
||||
despu<EFBFBD>s del simbolo '->'.
|
||||
</para>
|
||||
<example>
|
||||
<title>Accesando propiedades de objetos</title>
|
||||
<title>Accesando propiedades de los Objetos</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
name: {$person->name}<br />
|
||||
@@ -142,7 +164,7 @@ email: {$person->email}<br />
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
this will output:
|
||||
esta es la salida:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -153,6 +175,7 @@ email: zaphod@slartibartfast.com<br />
|
||||
</example>
|
||||
</sect2>
|
||||
</sect1>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
|
@@ -3,7 +3,8 @@
|
||||
<sect1 id="language.config.variables">
|
||||
<title>Variables cargadas desde archivos de configuraci<63>n</title>
|
||||
<para>
|
||||
Las variables que son cargadas de archivos de configuraci<63>n son
|
||||
Las variables que son cargadas de
|
||||
<link linkend="config.files">archivos de configuraci<63>n</link> son
|
||||
referenciadas incluyendo entre ellas el signo(#), o como variables
|
||||
de Smarty
|
||||
<link linkend="language.variables.smarty.config">$smarty.config</link>.
|
||||
@@ -45,7 +46,7 @@ rowBgColor = "#cccccc"
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
index.tpl: (alternate syntax)
|
||||
index.tpl: (sintaxis alternativa)
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
@@ -65,7 +66,7 @@ rowBgColor = "#cccccc"
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
this will output for both examples:
|
||||
esta es la salida de ambos ejemplos:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
@@ -89,8 +90,13 @@ rowBgColor = "#cccccc"
|
||||
usadas hasta despu<70>s de que son cargadas por los archivos de
|
||||
configuraci<63>n.
|
||||
Este procedimento es explicado posteriormente en este documento en
|
||||
<command>config_load</command>.
|
||||
<link linkend="language.function.config.load"><command>{config_load}</command></link>.
|
||||
</para>
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="language.syntax.variables">Variables</link> y
|
||||
<link linkend="language.variables.smarty">$smarty reserved variables</link>
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -10,11 +10,14 @@
|
||||
<sect2 id="language.variables.smarty.request">
|
||||
<title>Solicitud de Variables</title>
|
||||
<para>
|
||||
La solicitud de variables como get, post, cookies, server, environment, y
|
||||
session pueden ser accesadas como se muestra en los ejemplos de abajo:
|
||||
La <ulink url="&url.php-manual;reserved.variables">solicitud de variables</ulink>
|
||||
como $_GET, $_POST, $_COOKIE, $_SERVER, $_ENV y $_SESSION
|
||||
(Ver <link linkend="variable.request.vars.order">$request_vars_order</link>
|
||||
y <link linkend="variable.request.use.auto.globals">$request_use_auto_globals</link>)
|
||||
pueden ser accesadas como se muestra en los ejemplos de abajo:
|
||||
</para>
|
||||
<example>
|
||||
<title>Mostrando peticiones de variables</title>
|
||||
<title>Mostrando solicitud de variables</title>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* display value of page from URL (GET) http://www.domain.com/index.php?page=foo *}
|
||||
@@ -52,10 +55,12 @@
|
||||
<sect2 id="language.variables.smarty.now">
|
||||
<title>{$smarty.now}</title>
|
||||
<para>
|
||||
El timestamp actual puede ser accesado con {$smarty.now}.
|
||||
El n<>mero refleja el n<>mero de segundos pasados desde la
|
||||
llamada Epoca (1 de Enero de 1970) y puede ser pasado directamente
|
||||
para el modificador date_format para mostrar la fecha.
|
||||
El <ulink url="&url.php-manual;function.time">timestamp</ulink>
|
||||
actual puede ser accesado con {$smarty.now}. El n<>mero refleja el
|
||||
n<EFBFBD>mero de segundos pasados desde la llamada Epoca (1 de Enero de 1970)
|
||||
y puede ser pasado directamente para el modificador
|
||||
<link linkend="language.modifier.date.format">date_format</link> para
|
||||
mostrar la fecha.
|
||||
</para>
|
||||
<example>
|
||||
<title>Usando {$smarty.now}</title>
|
||||
@@ -70,7 +75,9 @@
|
||||
<sect2 id="language.variables.smarty.const">
|
||||
<title>{$smarty.const}</title>
|
||||
<para>
|
||||
Usted puede accesar el valor de constantes PHP directamente.
|
||||
Usted puede accesar al valor de constantes PHP directamente.
|
||||
Ver tambi<62>n <link linkend="smarty.constants">smarty constants</link>
|
||||
|
||||
</para>
|
||||
<example>
|
||||
<title>Usando {$smarty.const}</title>
|
||||
@@ -85,9 +92,10 @@
|
||||
<sect2 id="language.variables.smarty.capture">
|
||||
<title>{$smarty.capture}</title>
|
||||
<para>
|
||||
La salida capturada via {capture}..{/capture} puede ser accesada
|
||||
usando la variable {$smarty}.
|
||||
vea la secci<63>n <link linkend="language.function.capture">capture</link>
|
||||
La salida capturada via
|
||||
<link linkend="language.function.capture">{capture}..{/capture}</link>
|
||||
puede ser accesada usando la variable {$smarty}.
|
||||
vea la secci<63>n <link linkend="language.function.capture">{capture}</link>
|
||||
para un ejemplo.
|
||||
</para>
|
||||
</sect2>
|
||||
@@ -95,10 +103,10 @@
|
||||
<sect2 id="language.variables.smarty.config">
|
||||
<title>{$smarty.config}</title>
|
||||
<para>
|
||||
La variable {$smarty} puede ser usada para referir variables de
|
||||
configuraci<EFBFBD>n cargadas.
|
||||
{$smarty.config.foo} es un sin<69>nimo para {#foo#}. vea la secci<63>n
|
||||
sobre <link linkend="language.function.config.load">config_load</link>
|
||||
La variable {$smarty} puede ser usada para referir
|
||||
<link linkend="language.config.variables">variables de configuraci<63>n</link>
|
||||
cargadas. {$smarty.config.foo} es un sin<69>nimo para {#foo#}. vea la secci<63>n
|
||||
sobre <link linkend="language.function.config.load">{config_load}</link>
|
||||
para un ejemplo.
|
||||
</para>
|
||||
</sect2>
|
||||
@@ -123,25 +131,20 @@
|
||||
<sect2 id="language.variables.smarty.version">
|
||||
<title>{$smarty.version}</title>
|
||||
<para>
|
||||
Esta variable contiene la versi<73>n Smarty con que es compilado el
|
||||
template.
|
||||
Esta variable contiene la versi<73>n Smarty con que es compilado el template.
|
||||
</para>
|
||||
</sect2>
|
||||
<sect2 id="language.variables.smarty.ldelim">
|
||||
<title>{$smarty.ldelim}</title>
|
||||
<title>{$smarty.ldelim}, {$smarty.rdelim}</title>
|
||||
<para>
|
||||
Esta variable es usada para imprimir literalmente el valor left-delimiter.
|
||||
Esta variable es usada para imprimir literalmente el valor left-delimiter y right-delimiter.
|
||||
Ver tambien <link linkend="language.function.ldelim">{ldelim},{rdelim}</link>.
|
||||
</para>
|
||||
</sect2>
|
||||
<sect2 id="language.variables.smarty.rdelim">
|
||||
<title>{$smarty.rdelim}</title>
|
||||
<para>
|
||||
Esta variable es usada para imprimir literalmente el valor right-delimiter.
|
||||
Ver tambien <link linkend="language.function.ldelim">{rdelim},{rdelim}</link>.
|
||||
Ver tambi<62>n <link linkend="language.syntax.variables">Variables</link>
|
||||
y <link linkend="language.config.variables">Config Variables</link>
|
||||
</para>
|
||||
</sect2>
|
||||
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
|
@@ -11,7 +11,10 @@
|
||||
contenido en la presentaci<63>n.
|
||||
La mejor descripci<63>n esta en una situaci<63>n donde la aplicaci<63>n
|
||||
del programador y la plantilla del dise<73>ador juegan diferentes roles,
|
||||
o en la mayoria de los casos no la misma persona. Por ejemplo:
|
||||
o en la mayoria de los casos no la misma persona.
|
||||
</para>
|
||||
<para>
|
||||
Por ejemplo:
|
||||
Digamos que usted crea una pagina web, es decir, despliega el articulo
|
||||
de un diario. El encabezado del articulo, el rotulo, el autor y el
|
||||
cuerpo son elementos del contenido, estos no contiene informaci<63>n de
|
||||
@@ -31,6 +34,18 @@
|
||||
plantilla puede hacer cambios sin que haya rompimiento con la aplicaci<63>n
|
||||
l<>gica.
|
||||
</para>
|
||||
<para>
|
||||
One design goal of Smarty is the separation of business logic and
|
||||
presentation logic. This means templates can certainly contain logic under
|
||||
the condition that it is for presentation only. Things such as including
|
||||
other templates, altering table row colors, upper-casing a variable,
|
||||
looping over an array of data and displaying it, etc. are all examples of
|
||||
presentation logic. This does not mean that Smarty forces a separation of
|
||||
business and presentation logic. Smarty has no knowledge of which is which,
|
||||
so placing business logic in the template is your own doing. Also, if you
|
||||
desire <emphasis>no</emphasis> logic in your templates you certainly can
|
||||
do so by boiling the content down to text and variables only.
|
||||
</para>
|
||||
<para>
|
||||
Ahora un peque<75>o resumen sobre que no hace Smarty. Smarty no intenta
|
||||
separar completamente la l<>gica de la plantilla. No hay problema entre la
|
||||
@@ -158,7 +173,7 @@ Smarty.class.php
|
||||
Smarty_Compiler.class.php
|
||||
Config_File.class.php
|
||||
debug.tpl
|
||||
/core/*.php (all of them)
|
||||
/internals/*.php (all of them)
|
||||
/plugins/*.php (all of them)
|
||||
]]>
|
||||
</screen>
|
||||
@@ -166,11 +181,11 @@ debug.tpl
|
||||
<para>
|
||||
Smarty utiliza una constante de PHP llamada <link
|
||||
linkend="constant.smarty.dir">SMARTY_DIR</link> que es la ruta para
|
||||
el directorio de la biblioteca de Smarty. Basicamente, si su
|
||||
aplicaci<63>n puede encontrar el archivo <emphasis>Smarty.class.php
|
||||
</emphasis>, usted no necesita definir SMARTY_DIR, Smarty lo
|
||||
encontrar<61>. Por consiguiente si, <emphasis>Smarty.class.php
|
||||
</emphasis> no esta incluido en el path, y no es abastecido por
|
||||
el directorio de la biblioteca de Smarty 'libs/'. Basicamente, si su
|
||||
aplicaci<63>n puede encontrar el archivo <filename>Smarty.class.php
|
||||
</filename>, usted no necesita definir <link linkend="constant.smarty.dir">SMARTY_DIR</link>,
|
||||
Smarty lo encontrar<EFBFBD>. Por consiguiente si, <filename>Smarty.class.php
|
||||
</filename> no esta incluido en el path, y no es abastecido por
|
||||
una ruta absoluta para encontrar su aplicaci<63>n, entonces usted
|
||||
debe definir SMARTY_DIR manualmente. SMARTY_DIR <emphasis>debe
|
||||
</emphasis> incluir una barra de seguimento.
|
||||
@@ -194,7 +209,7 @@ $smarty = new Smarty;
|
||||
|
||||
<para>
|
||||
Intente correr el script de arriba. Si usted obtiene un error diciendo que
|
||||
el archivo <emphasis>Smarty.class.php</emphasis>
|
||||
el archivo <filename>Smarty.class.php</filename>
|
||||
no fue encontrado, puedes usar una de las siguientes opciones:
|
||||
</para>
|
||||
|
||||
@@ -216,11 +231,9 @@ $smarty = new Smarty;
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// Edite su archivo php.ini, y adicione el directorio de la
|
||||
// biblioteca de Smarty
|
||||
// Edite su archivo php.ini, y adicione el directorio de la libreria de Smarty
|
||||
// include_path y reinicie su servidor web.
|
||||
// Entonces lo siguiente debe funcionar:
|
||||
|
||||
require('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
?>
|
||||
@@ -244,19 +257,32 @@ $smarty = new Smarty;
|
||||
<para>
|
||||
Ahora que la libreria de archivos esta en su sitio, es tiempo
|
||||
de configurar los directorios de Smarty para su aplicaci<63>n.
|
||||
</para>
|
||||
<para>
|
||||
Smarty require cuatro directorios (por defaul) llamados
|
||||
<emphasis>templates</emphasis>, <emphasis>templates_c</emphasis>,
|
||||
<emphasis>configs</emphasis> y <emphasis>cache</emphasis>. Cada
|
||||
uno de estos son para definir las propiedades de las clases de Smarty.
|
||||
<emphasis>$template_dir</emphasis>, <emphasis>$compile_dir</emphasis>,
|
||||
<emphasis>$config_dir</emphasis>, y <emphasis>$cache_dir</emphasis>
|
||||
respectivamente. Es altamente recomendado que usted configure un grupo
|
||||
<filename class="directory">'templates/'</filename>,
|
||||
<filename class="directory">'templates_c/'</filename>,
|
||||
<filename class="directory">'configs/'</filename> y
|
||||
<filename class="directory">'cache/'</filename>.
|
||||
</para>
|
||||
<para>
|
||||
Cada uno de estos son para definir las propiedades de las clases de Smarty.
|
||||
<link linkend="variable.template.dir">
|
||||
<varname>$template_dir</varname></link>,
|
||||
<link linkend="variable.compile.dir">
|
||||
<varname>$compile_dir</varname></link>,
|
||||
<link linkend="variable.config.dir">
|
||||
<varname>$config_dir</varname></link>, y
|
||||
<link linkend="variable.cache.dir">
|
||||
<varname>$cache_dir</varname></link> respectivamente.
|
||||
Es altamente recomendado que usted configure un grupo
|
||||
separado de estos directorios para cada aplicaci<63>n que utilice de Smarty.
|
||||
</para>
|
||||
<para>
|
||||
Asegurece que usted sabe la ubicaci<63>n del document root de su servidor
|
||||
web. En nuestro ejemplo, el document root esta en
|
||||
"/web/www.mydomain.com/docs/". Los directorios de Smarty solo son
|
||||
<filename class="directory">/web/www.example.com/docs/</filename>.
|
||||
Los directorios de Smarty solo son
|
||||
accesados por la libreria de Smarty y nunca son accesados directamente
|
||||
por el navegador. Por consiguiente para evitar cualquier preocupaci<63>n
|
||||
con la seguridad, es recomendado colocar estos directorios
|
||||
@@ -269,13 +295,13 @@ $smarty = new Smarty;
|
||||
Usted puede usar el mismo ambiente para cualquier aplicaci<63>n, solamente
|
||||
sustituya "guestbook" con el nombre de su aplicaci<63>n.
|
||||
Nosotros colocaremos nuestros directorios de Smarty dentro de
|
||||
"/web/www.mydomain.com/smarty/guestbook/".
|
||||
<filename class="directory">/web/www.example.com/smarty/guestbook/</filename>.
|
||||
</para>
|
||||
<para>
|
||||
Usted necesita tener por lo menos un archivo dentro de su document root,
|
||||
y que sea accesado por el navegador. Nosotros llamamos el script de
|
||||
"index.php", y lo colocamos en un subdirectorio dentro del document root
|
||||
llamado "/guestbook/".
|
||||
<emphasis>'index.php'</emphasis>, y lo colocamos en un subdirectorio dentro del
|
||||
document root llamado <filename class="directory">/guestbook/</filename>.
|
||||
</para>
|
||||
|
||||
<note>
|
||||
@@ -283,11 +309,16 @@ $smarty = new Smarty;
|
||||
<para>
|
||||
Es conveniente configurar el servidor de forma que "index.php" pueda
|
||||
ser identificado como el <20>ndice del direct<63>rio padre, de esta manera
|
||||
si usted accesa "http://www.mydomain.com/guestbook/", el script
|
||||
si usted accesa http://www.example.com/guestbook/, el script
|
||||
index.php ser<65> ejecutado sin "index.php" ni la URL.
|
||||
En Apache usted puede definir el sitio adicionando "index.php" en el
|
||||
final de su configuraci<63>n del directorio index
|
||||
(separando cada uno con espacios.)
|
||||
final de su configuraci<63>n del directorio <emphasis>DirectoryIndex</emphasis>
|
||||
(separando cada uno con espacios.) como en el ejemplo de httpd.conf.
|
||||
</para>
|
||||
<para>
|
||||
<emphasis>DirectoryIndex
|
||||
index.htm index.html index.php index.php3 default.html index.cgi
|
||||
</emphasis>
|
||||
</para>
|
||||
</note>
|
||||
|
||||
@@ -303,25 +334,27 @@ $smarty = new Smarty;
|
||||
/usr/local/lib/php/Smarty/Smarty_Compiler.class.php
|
||||
/usr/local/lib/php/Smarty/Config_File.class.php
|
||||
/usr/local/lib/php/Smarty/debug.tpl
|
||||
/usr/local/lib/php/Smarty/core/*.php
|
||||
/usr/local/lib/php/Smarty/internals/*.php
|
||||
/usr/local/lib/php/Smarty/plugins/*.php
|
||||
|
||||
/web/www.mydomain.com/smarty/guestbook/templates/
|
||||
/web/www.mydomain.com/smarty/guestbook/templates_c/
|
||||
/web/www.mydomain.com/smarty/guestbook/configs/
|
||||
/web/www.mydomain.com/smarty/guestbook/cache/
|
||||
/web/www.example.com/smarty/guestbook/templates/
|
||||
/web/www.example.com/smarty/guestbook/templates_c/
|
||||
/web/www.example.com/smarty/guestbook/configs/
|
||||
/web/www.example.com/smarty/guestbook/cache/
|
||||
|
||||
/web/www.mydomain.com/docs/guestbook/index.php
|
||||
/web/www.example.com/docs/guestbook/index.php
|
||||
]]>
|
||||
</screen>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
Smarty necesitara permisos de escritura para
|
||||
<emphasis>$compile_dir</emphasis> y <emphasis>$cache_dir</emphasis>,
|
||||
Smarty necesitara <emphasis role="bold">permisos de escritura</emphasis>
|
||||
(usuarios de windows ingnorar) para
|
||||
<link linkend="variable.compile.dir"><emphasis>$compile_dir</emphasis></link> y
|
||||
<link linkend="variable.cache.dir"><emphasis>$cache_dir</emphasis></link>,
|
||||
esto garantiza que el usuario del servidor pueda escribir en ellos.
|
||||
Este es generalmente el usuarios "nobody" y el grupo "nobody".
|
||||
Para X usuarios de sistema, el default es "www" y el grupo "www".
|
||||
Para usuarios con X sistema operativo, el default es "www" y el grupo "www".
|
||||
Si usted esta usando Apache, puede ver en su archivo httpd.conf
|
||||
(normalmente en "/usr/local/apache/conf/") cual es el usuario y
|
||||
grupo que estan siendo usados.
|
||||
@@ -331,11 +364,11 @@ $smarty = new Smarty;
|
||||
<title>Configurando permisos de archivos</title>
|
||||
<programlisting role="shell">
|
||||
<![CDATA[
|
||||
chown nobody:nobody /web/www.mydomain.com/smarty/guestbook/templates_c/
|
||||
chmod 770 /web/www.mydomain.com/smarty/guestbook/templates_c/
|
||||
chown nobody:nobody /web/www.example.com/smarty/guestbook/templates_c/
|
||||
chmod 770 /web/www.example.com/smarty/guestbook/templates_c/
|
||||
|
||||
chown nobody:nobody /web/www.mydomain.com/smarty/guestbook/cache/
|
||||
chmod 770 /web/www.mydomain.com/smarty/guestbook/cache/
|
||||
chown nobody:nobody /web/www.example.com/smarty/guestbook/cache/
|
||||
chmod 770 /web/www.example.com/smarty/guestbook/cache/
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
@@ -353,11 +386,12 @@ chmod 770 /web/www.mydomain.com/smarty/guestbook/cache/
|
||||
|
||||
<para>
|
||||
Nosotros necesitamos crear el archivo index.tpl, para que Smarty lo
|
||||
pueda cargar. Este estara localizado en su $template_dir.
|
||||
pueda cargar. Este estara localizado en su
|
||||
<link linkend="variable.template.dir">$template_dir</link>.
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>Editando /web/www.mydomain.com/smarty/guestbook/templates/index.tpl</title>
|
||||
<title>Editando /web/www.example.com/smarty/guestbook/templates/index.tpl</title>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
|
||||
@@ -371,9 +405,9 @@ Hello, {$name}!
|
||||
<note>
|
||||
<title>Nota T<>cnica:</title>
|
||||
<para>
|
||||
{* Smarty *} Esto es un comentario en el template.
|
||||
Este no es obligatorio, pero si una buena practica iniciar todos sus
|
||||
archivos de plantilla con estos comentarios.
|
||||
{* Smarty *} Esto es un <link linkend="language.syntax.comments">comentario
|
||||
</link> en el template. Este no es obligatorio, pero si una buena practica
|
||||
iniciar todos sus archivos de plantilla con estos comentarios.
|
||||
Esto hace facilmente reconocibles a los archivos a pesar la extenci<63>n
|
||||
del archivo. Por ejemplo, editores de texto pueden reconocer el archivo
|
||||
y habilitar un realce de sintaxis especial.
|
||||
@@ -390,7 +424,7 @@ Hello, {$name}!
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>Editando /web/www.mydomain.com/docs/guestbook/index.php</title>
|
||||
<title>Editando /web/www.example.com/docs/guestbook/index.php</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
@@ -400,10 +434,10 @@ require('Smarty.class.php');
|
||||
|
||||
$smarty = new Smarty;
|
||||
|
||||
$smarty->template_dir = '/web/www.mydomain.com/smarty/guestbook/templates/';
|
||||
$smarty->compile_dir = '/web/www.mydomain.com/smarty/guestbook/templates_c/';
|
||||
$smarty->config_dir = '/web/www.mydomain.com/smarty/guestbook/configs/';
|
||||
$smarty->cache_dir = '/web/www.mydomain.com/smarty/guestbook/cache/';
|
||||
$smarty->template_dir = '/web/www.example.com/smarty/guestbook/templates/';
|
||||
$smarty->compile_dir = '/web/www.example.com/smarty/guestbook/templates_c/';
|
||||
$smarty->config_dir = '/web/www.example.com/smarty/guestbook/configs/';
|
||||
$smarty->cache_dir = '/web/www.example.com/smarty/guestbook/cache/';
|
||||
|
||||
$smarty->assign('name','Ned');
|
||||
|
||||
@@ -418,18 +452,18 @@ $smarty->display('index.tpl');
|
||||
<para>
|
||||
En nuestro ejemplo, estamos configurando rutas absolutas para todos
|
||||
los directorios de Smarty.
|
||||
Si '/web/www.mydomain.com/smarty/guestbook/' est<73> dentro de su
|
||||
include_path de PHP, entonces estas declaraciones no son necesarias.
|
||||
Sin embargo, esto es mas eficiente y (por experiencia) tiene menos
|
||||
tendencia a errores en relaci<63>n a determinar las rutas absolutas.
|
||||
Esto garantiza que Smarty esta recibiendo los archivos del directorio
|
||||
que usted desea.
|
||||
Si <filename class="directory">/web/www.example.com/smarty/guestbook/
|
||||
</filename> est<73> dentro de su include_path de PHP, entonces estas
|
||||
declaraciones no son necesarias. Sin embargo, esto es mas eficiente y
|
||||
(por experiencia) tiene menos tendencia a errores en relaci<63>n a
|
||||
determinar las rutas absolutas. Esto garantiza que Smarty esta recibiendo
|
||||
los archivos del directorio que usted desea.
|
||||
</para>
|
||||
</note>
|
||||
|
||||
<para>
|
||||
Ahora carge el archivo index.php desde su navegador web. Usted debera
|
||||
ver "Hello, Ned!"
|
||||
Ahora carge el archivo <filename>index.php</filename> desde su navegador web.
|
||||
Usted debera ver "Hello, Ned!"
|
||||
</para>
|
||||
<para>
|
||||
Usted a completado la configuracion basica para el Smarty!
|
||||
@@ -447,8 +481,8 @@ $smarty->display('index.tpl');
|
||||
clases e iniciar su ambiente de Smarty. Es, en vez de configurar rutas
|
||||
de directorios repetidamente, asigne esas mismas a variables, etc.,
|
||||
nosotros podemos facilitar eso. Vamos a crear un nuevo directorio en
|
||||
"/php/includes/guestbook/" y llamemos al nuevo archivo "setup.php".
|
||||
En nuestro ejemplo, "/php/includes" est<73> en nuestro include_path.
|
||||
"/php/includes/guestbook/" y llamemos al nuevo archivo <filename>setup.php
|
||||
</filename>. En nuestro ejemplo, "/php/includes" est<73> en nuestro include_path.
|
||||
Verifique que usted tambi<62>n lo definio, o utilice rutas absolutas de
|
||||
los archivos.
|
||||
</para>
|
||||
@@ -472,14 +506,15 @@ class Smarty_GuestBook extends Smarty {
|
||||
function Smarty_GuestBook()
|
||||
{
|
||||
|
||||
// Class Constructor. These automatically get set with each new instance.
|
||||
// Class Constructor.
|
||||
// These automatically get set with each new instance.
|
||||
|
||||
$this->Smarty();
|
||||
|
||||
$this->template_dir = '/web/www.mydomain.com/smarty/guestbook/templates/';
|
||||
$this->compile_dir = '/web/www.mydomain.com/smarty/guestbook/templates_c/';
|
||||
$this->config_dir = '/web/www.mydomain.com/smarty/guestbook/configs/';
|
||||
$this->cache_dir = '/web/www.mydomain.com/smarty/guestbook/cache/';
|
||||
$this->template_dir = '/web/www.example.com/smarty/guestbook/templates/';
|
||||
$this->compile_dir = '/web/www.example.com/smarty/guestbook/templates_c/';
|
||||
$this->config_dir = '/web/www.example.com/smarty/guestbook/configs/';
|
||||
$this->cache_dir = '/web/www.example.com/smarty/guestbook/cache/';
|
||||
|
||||
$this->caching = true;
|
||||
$this->assign('app_name', 'Guest Book');
|
||||
@@ -496,7 +531,7 @@ class Smarty_GuestBook extends Smarty {
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>Editando /web/www.mydomain.com/docs/guestbook/index.php</title>
|
||||
<title>Editando /web/www.example.com/docs/guestbook/index.php</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
@@ -1,24 +1,23 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
|
||||
<!ENTITY note.parameter.merge '<note>
|
||||
<title>Technical Note</title>
|
||||
<title>Nota Tecnica</title>
|
||||
<para>
|
||||
The <parameter>merge</parameter> parameter respects array keys, so if
|
||||
you merge two numerically indexed arrays, they may overwrite each other
|
||||
or result in non-sequential keys. This is unlike the array_merge() function
|
||||
of PHP which wipes out numerical keys and renumbers them.
|
||||
El parametro <parameter>merge</parameter> es la llave respectiva del arreglo, asi si
|
||||
usted asocia dos arreglos indexados numericamente, estos se sobre escriben uno al otro o
|
||||
tener como resultado llaves no-secuenciales. Este es diferente a la funcion array_merge() de PHP
|
||||
la cual limpia las llaves numericas y las vuelve a renumerar.
|
||||
</para>
|
||||
</note>'>
|
||||
|
||||
<!ENTITY parameter.compileid '<para>
|
||||
As an optional third parameter, you can pass a <parameter>compile_id</parameter>.
|
||||
This is in the event that you want to compile different versions of
|
||||
the same template, such as having separate templates compiled
|
||||
for different languages. Another use for compile_id is when you
|
||||
use more than one $template_dir but only one $compile_dir. Set
|
||||
a separate <parameter>compile_id</parameter> for each $template_dir, otherwise
|
||||
templates of the same name will overwrite each other. You can
|
||||
also set the <link
|
||||
linkend="variable.compile.id">$compile_id</link> variable once
|
||||
instead of passing this to each call to this function.
|
||||
Como tercer parametro opcional, usted puede pasar <parameter>compile_id</parameter>.
|
||||
Este en el caso que usted quira compilar diferentes versiones del mismo Tempalte,
|
||||
tal como tener separadas varios Templates compilados de diferentes lenguajes.
|
||||
Otro uso para compile_id es cuando usted usa mas de un $template_dir pero solo un $compile_dir.
|
||||
Ponga separado <parameter>compile_id</parameter> por cada $template_dir, de otra manera
|
||||
los tempate con el mismo nombre se sobre escibiran uno sobre otro.
|
||||
Uste puede poner tambi<62>n la variable <link linkend="variable.compile.id">$compile_id</link>
|
||||
una vez en lugar de pasar esta por cada llamada a la funci<63>n.
|
||||
</para>'>
|
||||
|
37
docs/es/make_chm_index.html
Executable file
37
docs/es/make_chm_index.html
Executable file
@@ -0,0 +1,37 @@
|
||||
<HTML>
|
||||
<!-- $Revision$ -->
|
||||
<HEAD>
|
||||
<TITLE>Manual de Smarty</TITLE>
|
||||
<META NAME="HTTP_EQUIV" CONTENT="text/html; charset=ISO-8859-1">
|
||||
<LINK REL="STYLESHEET" HREF="style.css">
|
||||
</HEAD>
|
||||
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" TOPMARGIN="0" LEFTMARGIN="0">
|
||||
<TABLE BORDER="0" WIDTH="100%" HEIGHT="100%" CELLSPACING="0" CELLPADDING="0">
|
||||
<TR><TD COLSPAN="3"><DIV CLASS="NAVHEADER"><TABLE BGCOLOR="#CCCCFF" BORDER="0"
|
||||
CELLPADDING="0" CELLSPACING="0" WIDTH="100%"><TR><TD><TABLE WIDTH="100%" BORDER="0"
|
||||
CELLPADDING="3" CELLSPACING="0"><TR><TH COLSPAN="3">Manual de Smarty</TH></TR><TR><TD
|
||||
COLSPAN="3" ALIGN="center"> </TD></TR></TABLE></TD></TR><TR BGCOLOR="#333366">
|
||||
<TD><IMG SRC="spacer.gif" BORDER="0" WIDTH="1" HEIGHT="1"><BR></TD></TR></TABLE></DIV></TD></TR>
|
||||
<TR><TD><IMG SRC="spacer.gif" WIDTH="10" HEIGHT="1"></TD><TD HEIGHT="100%" VALIGN="MIDDLE" WIDTH="100%"><BR>
|
||||
|
||||
<P><TABLE ALIGN="CENTER">
|
||||
<TR><TD ALIGN="CENTER">
|
||||
<H1 CLASS="title">Smarty Manual</H1>
|
||||
<DIV CLASS="author">Monte Ohrt</DIV>
|
||||
<DIV CLASS="author">Andrei Zmievski</DIV>
|
||||
</TD></TR></TABLE>
|
||||
<BR><P ALIGN="CENTER">This file was generated: [GENTIME]<BR>
|
||||
Ir a <A HREF="http://smarty.php.net/download-docs.php">http://smarty.php.net/download-docs.php</A>
|
||||
para obtener la version actual.</P>
|
||||
|
||||
<BR><P CLASS="copyright" ALIGN="CENTER">Copyright © 2001 - 2005 New Digital Group, Inc.</P>
|
||||
|
||||
</TD><TD><IMG SRC="spacer.gif" WIDTH="10" HEIGHT="1"></TD></TR>
|
||||
<TR><TD COLSPAN="3"><DIV CLASS="NAVFOOTER"><TABLE BGCOLOR="#CCCCFF" BORDER="0"
|
||||
CELLPADDING="0" CELLSPACING="0" WIDTH="100%"><TR BGCOLOR="#333366">
|
||||
<TD><IMG SRC="spacer.gif" BORDER="0" WIDTH="1" HEIGHT="1"><BR></TD></TR>
|
||||
<TR><TD><TABLE WIDTH="100%" BORDER="0" CELLPADDING="3" CELLSPACING="0">
|
||||
<TR><TD COLSPAN="3"> </TD></TR><TR><TD COLSPAN="3" ALIGN="center"> </TD>
|
||||
</TR></TABLE></TD></TR></TABLE></DIV></TD></TR></TABLE>
|
||||
</BODY></HTML>
|
||||
|
@@ -4,21 +4,24 @@
|
||||
<title>Objetos</title>
|
||||
<para>
|
||||
El Smarty permite acceso a objetos de PHP a trav<61>s de sus templates.
|
||||
Hay dos formas de accesarlos. Una forma es registrando objetos para el
|
||||
Hay dos formas de accesarlos. Una forma es
|
||||
<link linkend="api.register.object">registrando objetos</link> para el
|
||||
template, entonces acceselos mediante sintaxis similar a las funciones
|
||||
habituales. La otra es asignar objetos al template y accesarlos como si
|
||||
fueran una variable asignada. El primer m<>todo tiene una sintaxis de
|
||||
template mucho mas agradable. Y tambi<62>n mas segura, a medida que un
|
||||
objeto registrado puede ser reescrito a ciertos m<>todos y propiedades.
|
||||
Sin embargo tanto, un objeto registrado no puede ser puesto en loop o
|
||||
ser asignado en arreglos de objetos, etc. El m<>todo que usted escoja
|
||||
sera determinado por sus necesidades, pero utilice el primero m<>todo si
|
||||
es posible para mantener un minimo de sintaxis en el template.
|
||||
habituales. La otra es <link linkend="api.assign">asignar objetos</link> al
|
||||
template y accesarlos como si fueran una variable asignada. El primer m<>todo
|
||||
tiene una sintaxis de template mucho mas agradable. Y tambi<62>n mas segura, a
|
||||
medida que un objeto registrado puede ser reescrito a ciertos m<>todos y
|
||||
propiedades. Sin embargo tanto, <emphasis role="bold">un objeto registrado
|
||||
no puede ser puesto en loop o ser asignado en arreglos de objetos</emphasis>,
|
||||
etc. El m<>todo que usted escoja sera determinado por sus necesidades, pero
|
||||
utilice el primero m<>todo si es posible para mantener un minimo de sintaxis
|
||||
en el template.
|
||||
</para>
|
||||
<para>
|
||||
Si la seguridad esta habilitada, ninguno de los dos m<>todos privados o
|
||||
funciones pueden ser accesados (comenzando con "_"). Si un metodo y
|
||||
propiedades de un mismo nombre existe, el m<>todo ser<65> usado.
|
||||
Si <link linkend="variable.security">$security</link> esta habilitada,
|
||||
ninguno de los dos m<>todos privados o funciones pueden ser accesados
|
||||
(comenzando con "_"). Si un metodo y propiedades de un mismo nombre existe,
|
||||
el m<>todo ser<65> usado.
|
||||
</para>
|
||||
<para>
|
||||
Usted puede restringir los m<>todos y propiedades que pueden ser accesados
|
||||
@@ -26,12 +29,12 @@
|
||||
</para>
|
||||
<para>
|
||||
Por default, los par<61>metros pasados a los objetos a a trav<61>s de los
|
||||
templates son pasados de la misma forma en que las funciones de
|
||||
costumbre los obtienen. Un arreglo asociativo es pasado como el primer
|
||||
par<EFBFBD>metro, y el objeto smarty como el segundo. Si usted quiere que los
|
||||
par<EFBFBD>metros pasados uno de cada vez por cada argumento pasen como
|
||||
par<EFBFBD>metros de un objeto tradicional, defina el cuarto par<61>metro de
|
||||
registro en falso.
|
||||
templates son pasados de la misma forma en que las
|
||||
<link linkend="language.custom.functions">funciones de costumbre</link>
|
||||
los obtienen. Un arreglo asociativo es pasado como el primer par<61>metro,
|
||||
y el objeto smarty como el segundo. Si usted quiere que los par<61>metros
|
||||
pasados uno de cada vez por cada argumento pasen como par<61>metros de un
|
||||
objeto tradicional, defina el cuarto par<61>metro de registro en falso.
|
||||
</para>
|
||||
<para>
|
||||
El quinto par<61>metro opcional solo tiene efecto con
|
||||
@@ -41,10 +44,13 @@
|
||||
etiqueta de cierre en el template
|
||||
(<literal>{foobar->meth2}...{/foobar->meth2}</literal>) y
|
||||
los par<61>metros para los m<>todos tienen la misma sinopsis como
|
||||
los par<61>metros de block-function-plugins: Ellos reciben 4
|
||||
par<EFBFBD>metros <parameter>$params</parameter>,
|
||||
<parameter>$content</parameter>,<parameter>&$smarty</parameter>
|
||||
y <parameter>&$repeat</parameter> tambi<62>n se comportan como
|
||||
los par<61>metros de <link
|
||||
linkend="plugins.block.functions">block-function-plugins</link>:
|
||||
Ellos reciben 4 par<EFBFBD>metros
|
||||
<parameter>$params</parameter>,
|
||||
<parameter>$content</parameter>,
|
||||
<parameter>&$smarty</parameter> y
|
||||
<parameter>&$repeat</parameter> tambi<62>n se comportan como
|
||||
block-function-plugins.
|
||||
</para>
|
||||
<example>
|
||||
@@ -52,7 +58,7 @@
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// El objeto
|
||||
// el objeto
|
||||
|
||||
class My_Object {
|
||||
function meth1($params, &$smarty_obj) {
|
||||
@@ -61,27 +67,25 @@ class My_Object {
|
||||
}
|
||||
|
||||
$myobj = new My_Object;
|
||||
|
||||
// registrando el objeto (ser<65> por referencia)
|
||||
$smarty->register_object("foobar",$myobj);
|
||||
|
||||
// Si usted quiere restringir acceso a ciertos metodos o propriedades,
|
||||
// listelos
|
||||
// Si usted quiere restringir acceso a ciertos metodos o propriedades, listelos
|
||||
$smarty->register_object("foobar",$myobj,array('meth1','meth2','prop1'));
|
||||
|
||||
// Si usted quiere usar el formato de parámetro del objeto tradicional,
|
||||
// pase un booleano en false
|
||||
// Si usted quiere usar el formato de par<61>metro del objeto tradicional, pase un booleano en false
|
||||
$smarty->register_object("foobar",$myobj,null,false);
|
||||
|
||||
// también puede asignar ojetos. Posible cuando se asignan por
|
||||
// referencia.
|
||||
// tambi<EFBFBD>n puede asignar ojetos. Posible cuando se asignan por referencia.
|
||||
$smarty->assign_by_ref("myobj", $myobj);
|
||||
|
||||
$smarty->display("index.tpl");
|
||||
?>
|
||||
|
||||
TEMPLATE:
|
||||
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
y como debera accesar a su objeto en index.tpl
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* accesando a nuestro objeto registrado *}
|
||||
{foobar->meth1 p1="foo" p2=$bar}
|
||||
|
||||
|
@@ -26,7 +26,6 @@
|
||||
<![CDATA[
|
||||
<?php
|
||||
// ponga esto en su aplicaci<63>n
|
||||
|
||||
function protect_email($tpl_output, &$smarty)
|
||||
{
|
||||
$tpl_output =
|
||||
@@ -41,7 +40,6 @@ $smarty->display("index.tpl");
|
||||
|
||||
// Ahora cualquier ocurrencia de una dirección de email en la salida
|
||||
// del template tendra una simple protección contra spambots
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
@@ -29,12 +29,17 @@ function add_header_comment($tpl_source, &$smarty)
|
||||
$smarty->register_postfilter("add_header_comment");
|
||||
$smarty->display("index.tpl");
|
||||
?>
|
||||
|
||||
{* compiled Smarty template index.tpl *}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Observe como hacer la compilacion para Smarty del template index.tpl:
|
||||
</para>
|
||||
<screen>
|
||||
<![CDATA[
|
||||
<!-- Created by Smarty! -->
|
||||
{* rest of template content... *}
|
||||
]]>
|
||||
</programlisting>
|
||||
</screen>
|
||||
</example>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -7,12 +7,16 @@
|
||||
templates antes de ser compilados. Esto es bueno para procesar
|
||||
por adelantado sus templates y remover comentarios no deseados,
|
||||
vigilando a las personas que coloquen en sus templates, etc.
|
||||
</para>
|
||||
<para>
|
||||
Los Prefilters pueden ser
|
||||
<link linkend="api.register.prefilter">registrado</link>
|
||||
o cargado del directorio de plugins usando la funci<63>n
|
||||
<link linkend="api.load.filter">load_filter()</link> o por la
|
||||
configuraci<63>n de la variable
|
||||
<link linkend="variable.autoload.filters">$autoload_filters</link>.
|
||||
</para>
|
||||
<para>
|
||||
El Smarty pasara el c<>digo fuente del template como el primer argumento,
|
||||
y espera que la funci<63>n le retorne el c<>digo fuente del template
|
||||
resultante.
|
||||
@@ -32,11 +36,11 @@ function remove_dw_comments($tpl_source, &$smarty)
|
||||
$smarty->register_prefilter("remove_dw_comments");
|
||||
$smarty->display("index.tpl");
|
||||
?>
|
||||
|
||||
{* Smarty template index.tpl *}
|
||||
<!--# esta linea ser<65> eliminada por el prefilter -->
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Esto eliminara todos los comentarios en el codigo del template.
|
||||
</para>
|
||||
</example>
|
||||
</sect1>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -3,10 +3,9 @@
|
||||
<sect1 id="section.template.cache.handler.func">
|
||||
<title>Funci<EFBFBD>n manipuladora de cache</title>
|
||||
<para>
|
||||
Como una alternativa al uso del mecanismo de caching por default
|
||||
basado en archivo, usted puede especificar una funci<63>n habitual
|
||||
de manipulaci<EFBFBD>n de cache que ser<65> usada para leer, escribir y
|
||||
limpar archivos de cache.
|
||||
Como una alternativa al uso del mecanismo de caching por default basado
|
||||
en archivo, usted puede especificar una funci<63>n habitual de manipulaci<63>n
|
||||
de cache que ser<65> usada para leer, escribir y limpar archivos de cache.
|
||||
</para>
|
||||
<para>
|
||||
Cree una funci<63>n en su aplicaci<63>n para que Smarty la use como un
|
||||
@@ -83,9 +82,9 @@ function mysql_cache_handler($action, &$smarty_obj, &$cache_content, $tpl_file=n
|
||||
$row = mysql_fetch_array($results,MYSQL_ASSOC);
|
||||
|
||||
if($use_gzip && function_exists("gzuncompress")) {
|
||||
$cache_contents = gzuncompress($row["CacheContents"]);
|
||||
$cache_content = gzuncompress($row["CacheContents"]);
|
||||
} else {
|
||||
$cache_contents = $row["CacheContents"];
|
||||
$cache_content = $row["CacheContents"];
|
||||
}
|
||||
$return = $results;
|
||||
break;
|
||||
|
@@ -4,7 +4,9 @@
|
||||
<title>Recursos</title>
|
||||
<para>
|
||||
Los templates pueden venir de una variedad de fuentes. Cuando usted
|
||||
muestra un template con (display) o (fetch), o incluye un template
|
||||
muestra un template con
|
||||
<link linkend="api.display">display()</link> o
|
||||
<link linkend="api.fetch">fetch()</link>, o incluye un template
|
||||
dentro de otro template, usted suministra un tipo de recurso, seguido
|
||||
por la ruta correcta y el nombre del template.
|
||||
Si un recurso no es dado explicitamente el valor de
|
||||
@@ -12,23 +14,24 @@
|
||||
es asumido.
|
||||
</para>
|
||||
<sect2 id="templates.from.template.dir">
|
||||
<title>Templates partiendo del $template_dir</title>
|
||||
<title>Templates desde $template_dir</title>
|
||||
<para>
|
||||
Los templates desde el $template_dir no requieren recursos del
|
||||
template, aunque usted puede usar el file: resource for
|
||||
Los templates desde el
|
||||
<link linkend="variable.template.dir">$template_dir</link> no requieren
|
||||
recursos del template, aunque usted puede usar el file: resource for
|
||||
consistancy(recurso por consistencia). Justamente proporcionando
|
||||
la ruta(path) del template que usted quiere usar en relaci<63>n al
|
||||
directorio root $template_dir.
|
||||
directorio root <link linkend="variable.template.dir">$template_dir</link>.
|
||||
</para>
|
||||
<example>
|
||||
<title>Usando templates partiendo del $template_dir</title>
|
||||
<title>Usando templates desde $template_dir</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// desde el script de PHP
|
||||
$smarty->display("index.tpl");
|
||||
$smarty->display("admin/menu.tpl");
|
||||
$smarty->display("file:admin/menu.tpl"); // agual al de arriba
|
||||
$smarty->display("file:admin/menu.tpl"); // igual al de arriba
|
||||
?>
|
||||
|
||||
{* dentro del template de Smarty *}
|
||||
@@ -41,12 +44,13 @@ $smarty->display("file:admin/menu.tpl"); // agual al de arriba
|
||||
<sect2 id="templates.from.any.dir">
|
||||
<title>Templates partiendo de cualquier directorio</title>
|
||||
<para>
|
||||
Los templates de fuera del $template_dir requieren el file: tipo
|
||||
de recurso del template, seguido por la ruta absoluta y el nombre
|
||||
del template.
|
||||
Los templates de fuera del
|
||||
<link linkend="variable.template.dir">$template_dir</link> requieren
|
||||
el file: tipo de recurso del template, seguido por la ruta absoluta
|
||||
y el nombre del template.
|
||||
</para>
|
||||
<example>
|
||||
<title>usando templates partiendo de cualquier directorio</title>
|
||||
<title>usando templates desde cualquier directorio</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
@@ -54,8 +58,13 @@ $smarty->display("file:admin/menu.tpl"); // agual al de arriba
|
||||
$smarty->display("file:/export/templates/index.tpl");
|
||||
$smarty->display("file:/path/to/my/templates/menu.tpl");
|
||||
?>
|
||||
|
||||
{* desde adentro del template Smarty *}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
dentro del template Smarty:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{include file="file:/usr/local/share/templates/navigation.tpl"}
|
||||
]]>
|
||||
</programlisting>
|
||||
@@ -79,8 +88,13 @@ $smarty->display("file:/path/to/my/templates/menu.tpl");
|
||||
$smarty->display("file:C:/export/templates/index.tpl");
|
||||
$smarty->display("file:F:/path/to/my/templates/menu.tpl");
|
||||
?>
|
||||
|
||||
{* dentro del template de Smarty *}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
dentro del template de Smarty
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{include file="file:D:/usr/local/share/templates/navigation.tpl"}
|
||||
]]>
|
||||
</programlisting>
|
||||
@@ -118,7 +132,7 @@ $smarty->display("file:F:/path/to/my/templates/menu.tpl");
|
||||
// ponga estas funciones en algun lugar de su aplicaci<63>n
|
||||
function db_get_template ($tpl_name, &$tpl_source, &$smarty_obj)
|
||||
{
|
||||
// ejecutar la base de datos madar llamar aqu<71> su template,
|
||||
// llame su base de datos parta traer los datos al template,
|
||||
// poblando el $tpl_source
|
||||
|
||||
$sql = new SQL;
|
||||
@@ -135,8 +149,7 @@ function db_get_template ($tpl_name, &$tpl_source, &$smarty_obj)
|
||||
|
||||
function db_get_timestamp($tpl_name, &$tpl_timestamp, &$smarty_obj)
|
||||
{
|
||||
// ejecutar la base de datos llamar aqu<71> para poblar
|
||||
// $tpl_timestamp.
|
||||
// llame su base de datos para traer los datos y poblar el $tpl_timestamp.
|
||||
$sql = new SQL;
|
||||
$sql->query("select tpl_timestamp
|
||||
from my_table
|
||||
@@ -169,8 +182,13 @@ $smarty->register_resource("db", array("db_get_template",
|
||||
// usando el recurso a partir del script PHP
|
||||
$smarty->display("db:index.tpl");
|
||||
?>
|
||||
|
||||
{* usando el recurso dentro del template de Smarty *}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
usando el recurso dentro del template de Smarty
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{include file="db:/extras/navigation.tpl"}
|
||||
]]>
|
||||
</programlisting>
|
||||
|
@@ -2,7 +2,7 @@
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.9 Maintainer: ramirez Status: ready -->
|
||||
<chapter id="api.functions">
|
||||
<title>Metodos</title>
|
||||
<title>La clase Methods() de Smarty</title>
|
||||
&programmers.api-functions.api-append;
|
||||
&programmers.api-functions.api-append-by-ref;
|
||||
&programmers.api-functions.api-assign;
|
||||
|
@@ -3,10 +3,10 @@
|
||||
<refentry id="api.append.by.ref">
|
||||
<refnamediv>
|
||||
<refname>append_by_ref</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refpurpose>pasando valores por referencia</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
<title>Descipci<EFBFBD>n</title>
|
||||
<methodsynopsis>
|
||||
<type>void</type><methodname>append_by_ref</methodname>
|
||||
<methodparam><type>string</type><parameter>varname</parameter></methodparam>
|
||||
@@ -14,9 +14,10 @@
|
||||
<methodparam choice="opt"><type>bool</type><parameter>merge</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Este es usado para adicionar valores al templete por referencia.
|
||||
Si usted adiciona una variable por referencia entonces cambiara su valor,
|
||||
el valor asignado sufrira el cambio tambi<62>n. Para objetos, append_by_ref()
|
||||
Este es usado para <link linkend="api.append">pasar</link> valores al
|
||||
templete por referencia. Si usted pasa una variable por referencia entonces
|
||||
cambiara su valor, el valor asignado sufrira el cambio tambi<62>n. Para
|
||||
<link linkend="advanced.features.objects">objetos</link>, append_by_ref()
|
||||
tambi<62>n envia una copia en memoria del objeto adicionado. Vea el manual de
|
||||
PHP en referenciando variables para una mejor explicaci<63>n del asunto.
|
||||
Si usted pasa el tercer par<61>metro en true, el valor ser<65> mezclado con el
|
||||
@@ -35,6 +36,11 @@ $smarty->append_by_ref("Address", $address);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="api.append">append()</link>
|
||||
y <link linkend="api.assign">assign()</link>.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -2,11 +2,11 @@
|
||||
<!-- $Revision$ -->
|
||||
<refentry id="api.append">
|
||||
<refnamediv>
|
||||
<refname>append</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refname>append()</refname>
|
||||
<refpurpose>agregando elementos a una matriz asignada</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
<title>Descripci<EFBFBD>n</title>
|
||||
<methodsynopsis>
|
||||
<type>void</type><methodname>append</methodname>
|
||||
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
||||
@@ -37,11 +37,17 @@ $smarty->append("Name", "Fred");
|
||||
$smarty->append("Address", $address);
|
||||
|
||||
// passing an associative array
|
||||
$smarty->append(array("city" => "Lincoln", "state" => "Nebraska"));
|
||||
$smarty->append(array('city' => 'Lincoln', 'state' => 'Nebraska'));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>Ver tambi<62>n
|
||||
<link linkend="api.append.by.ref">append_by_ref()</link>,
|
||||
<link linkend="api.assign">assign()</link>
|
||||
y
|
||||
<link linkend="api.get.template.vars">get_template_vars()</link>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -3,19 +3,19 @@
|
||||
<refentry id="api.assign.by.ref">
|
||||
<refnamediv>
|
||||
<refname>assign_by_ref</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refpurpose>pasando valores por referencia</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
<title>Descripci<EFBFBD>n</title>
|
||||
<methodsynopsis>
|
||||
<type>void</type><methodname>assign_by_ref</methodname>
|
||||
<methodparam><type>string</type><parameter>varname</parameter></methodparam>
|
||||
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Este es usado para asignar valores por referencia al template en vez
|
||||
de hacer una copia. Vea el manual de PHP en la parte sobre referencia
|
||||
de variables para una explicaci<63>n mas detallada.
|
||||
Este es usado para <link linkend="api.assign">asignar</link> valores por
|
||||
referencia al template en vez de hacer una copia. Vea el manual de PHP en
|
||||
la parte sobre referencia de variables para una explicaci<63>n mas detallada.
|
||||
</para>
|
||||
<note>
|
||||
<title>Nota T<>cnica</title>
|
||||
@@ -23,13 +23,13 @@
|
||||
Este es usado para asignar valores por referencia al template.
|
||||
Si ested asigna una variable por referencia entonces cambiara
|
||||
este valor, el valor asignado exprimentara el cambio tambi<62>n.
|
||||
Para objetos, assign_by_ref() tambi<62>n exite una copia del
|
||||
objetos asignado en memoria. Vea el manual de PHP en refereciando
|
||||
variables para una mejor explicaci<63>n.
|
||||
Para <link linkend="advanced.features.objects">objetos</link>,
|
||||
assign_by_ref() tambi<62>n exite una copia del objetos asignado en memoria.
|
||||
Vea el manual de PHP en refereciando variables para una mejor explicaci<63>n.
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>assign_by_ref</title>
|
||||
<title>assign_by_ref()</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
@@ -40,6 +40,13 @@ $smarty->assign_by_ref('Address', $address);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="api.assign">assign()</link>,
|
||||
<link linkend="api.clear.all.assign">clear_all_assign()</link>,
|
||||
<link linkend="api.append">append()</link>
|
||||
y <link linkend="language.function.assign">{assign}</link>
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -2,11 +2,11 @@
|
||||
<!-- $Revision$ -->
|
||||
<refentry id="api.assign">
|
||||
<refnamediv>
|
||||
<refname>assign</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refname>assign()</refname>
|
||||
<refpurpose>pasando valores para el template</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
<title>Descripci<EFBFBD>n</title>
|
||||
<methodsynopsis>
|
||||
<type>void</type><methodname>assign</methodname>
|
||||
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
||||
@@ -17,25 +17,57 @@
|
||||
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Este es usado para asignar valores al template. Usted puede
|
||||
explicitamente pasar pares de nombres/valores, o un arreglo
|
||||
Usted puede explicitamente pasar pares de nombres/valores, o un arreglo
|
||||
asociativo conteniendo el par de nombre/valor.
|
||||
</para>
|
||||
<example>
|
||||
<title>assign</title>
|
||||
<title>assign()</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// passing name/value pairs
|
||||
// pasando pares de nombre/valor
|
||||
$smarty->assign('Name', 'Fred');
|
||||
$smarty->assign('Address', $address);
|
||||
|
||||
// passing an associative array
|
||||
$smarty->assign(array("city" => "Lincoln", "state" => "Nebraska"));
|
||||
// pasando un arreglo asosiativo
|
||||
$smarty->assign(array('city' => 'Lincoln', 'state' => 'Nebraska'));
|
||||
|
||||
// pasando un row desde una base de datos (eg adodb)
|
||||
$sql = 'select id, name, email from contacts where contact ='.$id;
|
||||
$smarty->assign('contact', $db->getRow($sql));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Accesando estos en el template con
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{$Name}
|
||||
{$Address}
|
||||
{$city}
|
||||
{$state}
|
||||
|
||||
{$contact.id}, {$contact.name},{$contact.email}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Para ver una asignacion de arreglos mas compleja
|
||||
<link linkend="language.function.foreach">{foreach}</link>
|
||||
y
|
||||
<link linkend="language.function.section">{section}</link>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Vea tambi<62>n <link linkend="api.assign.by.ref">assign_by_ref()</link>,
|
||||
<link linkend="api.get.template.vars">get_template_vars()</link>,
|
||||
<link linkend="api.clear.assign">clear_assign()</link>,
|
||||
<link linkend="api.append">append()</link>
|
||||
y
|
||||
<link linkend="language.function.assign">{assign}</link>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -2,29 +2,43 @@
|
||||
<!-- $Revision$ -->
|
||||
<refentry id="api.clear.all.assign">
|
||||
<refnamediv>
|
||||
<refname>clear_all_assign</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refname>clear_all_assign()</refname>
|
||||
<refpurpose>>limpia el valor de todas las variables asignadas</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
<title>Descripci<EFBFBD>n</title>
|
||||
<methodsynopsis>
|
||||
<type>void</type><methodname>clear_all_assign</methodname>
|
||||
<void />
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Esto limpia el valor de todas las variables asignadas.
|
||||
</para>
|
||||
<example>
|
||||
<title>clear_all_assign</title>
|
||||
<title>clear_all_assign()</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// passing name/value pairs
|
||||
$smarty->assign('Name', 'Fred');
|
||||
$smarty->assign('Address', $address);
|
||||
|
||||
// will output above
|
||||
print_r( $smarty->get_template_vars() );
|
||||
|
||||
// clear all assigned variables
|
||||
$smarty->clear_all_assign();
|
||||
|
||||
// will output nothing
|
||||
print_r( $smarty->get_template_vars() );
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n
|
||||
<link linkend="api.clear.assign">clear_assign()</link>,
|
||||
<link linkend="api.clear.config">clear_config()</link>,
|
||||
<link linkend="api.assign">assign()</link>
|
||||
y <link linkend="api.append">append()</link>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -3,7 +3,7 @@
|
||||
<refentry id="api.clear.all.cache">
|
||||
<refnamediv>
|
||||
<refname>clear_all_cache</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refpurpose>limpia completamente el cache del template</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
@@ -12,9 +12,8 @@
|
||||
<methodparam choice="opt"><type>int</type><parameter>expire_time</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Esto limpia completamente el cache del template. Como un par<61>metro
|
||||
opcional, usted puede proporcionar un periodo minimo en segundos
|
||||
que el archivo de cache debe tener antes de ser anulado.
|
||||
Como un par<61>metro opcional, usted puede proporcionar un periodo minimo
|
||||
en segundos que el archivo de cache debe tener antes de ser anulado.
|
||||
</para>
|
||||
<example>
|
||||
<title>clear_all_cache</title>
|
||||
@@ -27,6 +26,13 @@ $smarty->clear_all_cache();
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n
|
||||
<link linkend="api.clear.cache">clear_cache()</link>,
|
||||
<link linkend="api.is.cached">is_cached()</link>
|
||||
y
|
||||
<link linkend="caching">caching</link>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -2,33 +2,40 @@
|
||||
<!-- $Revision$ -->
|
||||
<refentry id="api.clear.assign">
|
||||
<refnamediv>
|
||||
<refname>clear_assign</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refname>clear_assign()</refname>
|
||||
<refpurpose>limpia el valor de una variable asignada</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
<title> Descripci<63>n</title>
|
||||
<methodsynopsis>
|
||||
<type>void</type><methodname>clear_assign</methodname>
|
||||
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Esto limpia el valor de una viariable asignada. Este puede ser un
|
||||
valor simple, o un arreglo de valores.
|
||||
Este puede ser un valor simple, o un arreglo de valores.
|
||||
</para>
|
||||
<example>
|
||||
<title>clear_assign</title>
|
||||
<title>clear_assign()</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// clear a single variable
|
||||
$smarty->clear_assign("Name");
|
||||
$smarty->clear_assign('Name');
|
||||
|
||||
// clear multiple variables
|
||||
$smarty->clear_assign(array("Name", "Address", "Zip"));
|
||||
$smarty->clear_assign(array('Name', 'Address', 'Zip'));
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n
|
||||
<link linkend="api.clear.all.assign">clear_all_assign()</link>,
|
||||
<link linkend="api.clear.config">clear_config()</link>,
|
||||
<link linkend="api.get.template.vars">get_template_vars()</link>,
|
||||
<link linkend="api.assign">assign()</link>
|
||||
y <link linkend="api.append">append()</link>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -2,11 +2,11 @@
|
||||
<!-- $Revision$ -->
|
||||
<refentry id="api.clear.cache">
|
||||
<refnamediv>
|
||||
<refname>clear_cache</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refname>clear_cache()</refname>
|
||||
<refpurpose>Esto limpia el cache de un template especifico</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
<title>Descripci<EFBFBD>n</title>
|
||||
<methodsynopsis>
|
||||
<type>void</type><methodname>clear_cache</methodname>
|
||||
<methodparam><type>string</type><parameter>template</parameter></methodparam>
|
||||
@@ -15,31 +15,36 @@
|
||||
<methodparam choice="opt"><type>int</type><parameter>expire_time</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Esto limpia el cahce de un <parameter>template</parameter> especifico.
|
||||
Si usted tiene multiples caches en este archivo, usted puede limpiar un
|
||||
cache especifico proporcionando el <parameter>cache_id</parameter> como
|
||||
segundo par<EFBFBD>metro Usted tambi<62>n puede pasar el
|
||||
<parameter>compile_id</parameter> como un tercer par<61>metro.
|
||||
Usted puede "agrupar" templates conjuntamente de esta manera estos pueden
|
||||
ser removidos como un grupo. Vea el
|
||||
<link linkend="caching">caching section</link> para mayor informaci<63>n.
|
||||
Si usted tiene <link linkend="caching.multiple.caches">multiples</link> caches
|
||||
en este archivo, usted puede limpiar un cache especifico proporcionando el
|
||||
<parameter>cache_id</parameter> como segundo par<61>metro Usted tambi<62>n puede pasar
|
||||
el <link linkend="variable.compile.id"><parameter>$compile_id</parameter></link>
|
||||
como un tercer par<EFBFBD>metro. Usted puede <link linkend="caching.groups">"agrupar"</link>
|
||||
templates conjuntamente de esta manera estos pueden ser removidos como un grupo.
|
||||
Vea el <link linkend="caching">caching section</link> para mayor informaci<63>n.
|
||||
Como un cuarto par<61>metro opcional, usted puede proporcionar un periodo
|
||||
minimo en segundos que el archivo de cache debe tener antes de ser anulado.
|
||||
</para>
|
||||
<example>
|
||||
<title>clear_cache</title>
|
||||
<title>clear_cache()</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
// clear the cache for a template
|
||||
$smarty->clear_cache("index.tpl");
|
||||
$smarty->clear_cache('index.tpl');
|
||||
|
||||
// clear the cache for a particular cache id in an multiple-cache template
|
||||
$smarty->clear_cache("index.tpl", "CACHEID");
|
||||
$smarty->clear_cache('index.tpl', 'CACHEID');
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n
|
||||
<link linkend="api.clear.all.cache">clear_all_cache()</link>
|
||||
y
|
||||
<link linkend="caching">caching</link>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -2,11 +2,11 @@
|
||||
<!-- $Revision$ -->
|
||||
<refentry id="api.clear.compiled.tpl">
|
||||
<refnamediv>
|
||||
<refname>clear_compiled_tpl</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refname>clear_compiled_tpl()</refname>
|
||||
<refpurpose>Esto limpia la vesion compilada del recurso de un template especifico</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
<title>Descripci<EFBFBD>n</title>
|
||||
<methodsynopsis>
|
||||
<type>void</type><methodname>clear_compiled_tpl</methodname>
|
||||
<methodparam choice="opt"><type>string</type><parameter>tpl_file</parameter></methodparam>
|
||||
@@ -16,14 +16,16 @@
|
||||
<para>
|
||||
Esto limpia la versi<73>n compilada del recurso del template especificado,
|
||||
o todos los archivos de templates compilados si no fueron especificados.
|
||||
si usted lo pasa compile_is es limpiado. si usted lo pasa con ex_time,
|
||||
entonces solo compilara los templates anteriores al exp_time segundo
|
||||
seran limpiados, por default todos los templates son compilados y
|
||||
limpiados independientemente de su tiempo de vida.
|
||||
si usted pasa <link linkend="variable.compile.id">$compile_id</link> solo
|
||||
sera compilado este template especificado
|
||||
<link linkend="variable.compile.id">$compile_id</link> es limpiado.
|
||||
Si usted lo pasa con ex_time, entonces solo compilara los templates
|
||||
anteriores al exp_time segundo seran limpiados, por default todos los
|
||||
templates son compilados y limpiados independientemente de su tiempo de vida.
|
||||
Esta funci<63>n es solo para uso avanzado, normalmente no es necesaria.
|
||||
</para>
|
||||
<example>
|
||||
<title>clear_compiled_tpl</title>
|
||||
<title>clear_compiled_tpl()</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
@@ -2,22 +2,22 @@
|
||||
<!-- $Revision$ -->
|
||||
<refentry id="api.clear.config">
|
||||
<refnamediv>
|
||||
<refname>clear_config</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refname>clear_config()</refname>
|
||||
<refpurpose>Esto limpia todas las variables de configuraci<63>n</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
<title>Descripci<EFBFBD>n</title>
|
||||
<methodsynopsis>
|
||||
<type>void</type><methodname>clear_config</methodname>
|
||||
<methodparam choice="opt"><type>string</type><parameter>var</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Esto limpia todas las variables de configuraci<EFBFBD>n asignadas.
|
||||
Si es proporcionado el nombre de una variable, solamente esta
|
||||
variable es limpiada.
|
||||
Esto limpia todas las variables de
|
||||
<link linkend="language.config.variables">configuraci<EFBFBD>n asignadas</link>.
|
||||
Si es proporcionado el nombre de una variable, solo esa variable es limpiada.
|
||||
</para>
|
||||
<example>
|
||||
<title>clear_config</title>
|
||||
<title>clear_config()</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
@@ -30,6 +30,16 @@ $smarty->clear_config('foobar');
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n
|
||||
<link linkend="api.get.config.vars">get_config_vars()</link>,
|
||||
<link linkend="language.config.variables">config variables</link>,
|
||||
<link linkend="config.files">config files</link>,
|
||||
<link linkend="language.function.config.load">{config_load}</link>,
|
||||
<link linkend="api.config.load">config_load()</link>
|
||||
y
|
||||
<link linkend="api.clear.assign">clear_assign()</link>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -2,26 +2,27 @@
|
||||
<!-- $Revision$ -->
|
||||
<refentry id="api.config.load">
|
||||
<refnamediv>
|
||||
<refname>config_load</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refname>config_load()</refname>
|
||||
<refpurpose>Carga el archivo de configuraci<63>n y lo asigna al template</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
<title>Descripci<EFBFBD>n</title>
|
||||
<methodsynopsis>
|
||||
<type>void</type><methodname>config_load</methodname>
|
||||
<methodparam><type>string</type><parameter>file</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>string</type><parameter>section</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Esto carga el <parameter>archivo</parameter> de configuraci<63>n de
|
||||
Esto carga el <link linkend="config.files">archivo de configuraci<63>n</link> de
|
||||
datos y lo asigna al template. Esto funciona id<69>ntico a la funci<63>n
|
||||
<link linkend="language.function.config.load">config_load</link>.
|
||||
<link linkend="language.function.config.load">{config_load}</link>.
|
||||
</para>
|
||||
<note>
|
||||
<title>Nota T<>cnica</title>
|
||||
<para>
|
||||
A partir de Smarty 2.4.0, las variables de template asignadas son
|
||||
mantenidas a trav<61>s de fetch() y display(). Las variables de
|
||||
mantenidas a trav<61>s de <link linkend="api.fetch">fetch()</link> y
|
||||
<link linkend="api.display">display()</link>. Las variables de
|
||||
configuraci<63>n cargadas de config_load() son siempre de alcance global.
|
||||
Los archivos de configuracion tambi<62>n son compilados para
|
||||
execución rapida, y respetar el
|
||||
@@ -31,7 +32,7 @@
|
||||
</para>
|
||||
</note>
|
||||
<example>
|
||||
<title>config_load</title>
|
||||
<title>config_load()</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
@@ -44,6 +45,14 @@ $smarty->config_load('my.conf', 'foobar');
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n
|
||||
<link linkend="language.function.config.load">{config_load}</link>,
|
||||
<link linkend="api.get.config.vars">get_config_vars()</link>,
|
||||
<link linkend="api.clear.config">clear_config()</link>,
|
||||
y
|
||||
<link linkend="language.config.variables">config variables</link>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -2,11 +2,11 @@
|
||||
<!-- $Revision$ -->
|
||||
<refentry id="api.display">
|
||||
<refnamediv>
|
||||
<refname>display</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refname>display()</refname>
|
||||
<refpurpose>Despliega el Template</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
<title>Descripci<EFBFBD>n </title>
|
||||
<methodsynopsis>
|
||||
<type>void</type><methodname>display</methodname>
|
||||
<methodparam><type>string</type><parameter>template</parameter></methodparam>
|
||||
@@ -14,7 +14,8 @@
|
||||
<methodparam choice="opt"><type>string</type><parameter>compile_id</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Este despliega el template. cargando un tipo valido de path
|
||||
Este despliega el template diferente de <link
|
||||
linkend="api.fetch">fetch()</link>. Cargando un tipo valido de path
|
||||
<link linkend="template.resources">template resource</link>.
|
||||
Como un segundo par<61>metro opcional, usted puede pasar un
|
||||
identificador de cache.
|
||||
@@ -23,7 +24,7 @@
|
||||
</para>
|
||||
¶meter.compileid;
|
||||
<example>
|
||||
<title>display</title>
|
||||
<title>display()</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
@@ -56,7 +57,8 @@ $smarty->display("index.tpl");
|
||||
</example>
|
||||
<para>
|
||||
Use la sintaxis <link linkend="template.resources">template resources</link>
|
||||
para mostrar archivos fuera del directorio $template_dir.
|
||||
para mostrar archivos fuera del directorio
|
||||
<link linkend="variable.template.dir">$template_dir</link>.
|
||||
</para>
|
||||
<example>
|
||||
<title>Ejemplos de recursos de la funci<63>n display</title>
|
||||
@@ -64,20 +66,24 @@ $smarty->display("index.tpl");
|
||||
<![CDATA[
|
||||
<?php
|
||||
// absolute filepath
|
||||
$smarty->display("/usr/local/include/templates/header.tpl");
|
||||
$smarty->display('/usr/local/include/templates/header.tpl');
|
||||
|
||||
// absolute filepath (same thing)
|
||||
$smarty->display("file:/usr/local/include/templates/header.tpl");
|
||||
$smarty->display('file:/usr/local/include/templates/header.tpl');
|
||||
|
||||
// windows absolute filepath (MUST use "file:" prefix)
|
||||
$smarty->display("file:C:/www/pub/templates/header.tpl");
|
||||
$smarty->display('file:C:/www/pub/templates/header.tpl');
|
||||
|
||||
// include from template resource named "db"
|
||||
$smarty->display("db:header.tpl");
|
||||
$smarty->display('db:header.tpl');
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="api.fetch">fetch()</link> y
|
||||
<link linkend="api.template.exists">template_exists()</link>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -2,19 +2,20 @@
|
||||
<!-- $Revision$ -->
|
||||
<refentry id="api.fetch">
|
||||
<refnamediv>
|
||||
<refname>fetch</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refname>fetch()</refname>
|
||||
<refpurpose>Retorna la salida del template</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
<title>Descripci<EFBFBD>n</title>
|
||||
<methodsynopsis>
|
||||
<type>string</type><methodname>fetch</methodname>
|
||||
<methodparam><type>string</type><parameter>template</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>string</type><parameter>cache_id</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>string</type><parameter>compile_id</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>string</type><parameter>$compile_id</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Este retorna la salida del template en vez de desplegarla.
|
||||
Este retorna la salida del template en vez de
|
||||
<link linkend="api.display">desplegarla</link>.
|
||||
Proporcionando un tipo y path valido
|
||||
<link linkend="template.resources">template resource</link>.
|
||||
Como un segundo par<61>metro opcional, usted puede pasar el
|
||||
@@ -23,36 +24,37 @@
|
||||
mayor informaci<63>n.
|
||||
</para>
|
||||
¶meter.compileid;
|
||||
|
||||
<para>
|
||||
<example>
|
||||
<title>fetch</title>
|
||||
<title>fetch()</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
include("Smarty.class.php");
|
||||
include('Smarty.class.php');
|
||||
$smarty = new Smarty;
|
||||
|
||||
$smarty->caching = true;
|
||||
|
||||
// only do db calls if cache doesn't exist
|
||||
if(!$smarty->is_cached("index.tpl")) {
|
||||
if(!$smarty->is_cached('index.tpl')) {
|
||||
|
||||
// dummy up some data
|
||||
$address = "245 N 50th";
|
||||
$address = '245 N 50th';
|
||||
$db_data = array(
|
||||
"City" => "Lincoln",
|
||||
"State" => "Nebraska",
|
||||
"Zip" => "68502"
|
||||
'City' => 'Lincoln',
|
||||
'State' => 'Nebraska',
|
||||
'Zip' => '68502'
|
||||
);
|
||||
|
||||
$smarty->assign("Name","Fred");
|
||||
$smarty->assign("Address",$address);
|
||||
$smarty->assign('Name','Fred');
|
||||
$smarty->assign('Address',$address);
|
||||
$smarty->assign($db_data);
|
||||
|
||||
}
|
||||
|
||||
// capture the output
|
||||
$output = $smarty->fetch("index.tpl");
|
||||
$output = $smarty->fetch('index.tpl');
|
||||
|
||||
// do something with $output here
|
||||
|
||||
@@ -62,8 +64,75 @@ echo $output;
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
<example>
|
||||
<title>Usando fetch() y enviando a un e-mail</title>
|
||||
<para>
|
||||
El template email_body.tpl
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
Dear {$contact.name},
|
||||
|
||||
Welcome and thankyou for signing up as a member of our user group,
|
||||
|
||||
Click on the link below to login with your user name of '{$contact.login_id}'
|
||||
so you can post in our forums.
|
||||
|
||||
http://{$smarty.server.SERVER_NAME}/index.php?page=login
|
||||
|
||||
List master
|
||||
Some user group
|
||||
|
||||
{include file="email_disclaimer.tpl"}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
El template email_disclaimer.tpl usando el modificador
|
||||
<link linkend="language.function.textformat">{textformat}</link>.
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{textformat wrap=40}
|
||||
Unless you are named "{$contact.name}", you may read only the "odd numbered
|
||||
words" (every other word beginning with the first) of the message above. If you have
|
||||
violated that, then you hereby owe the sender 10 GBP for each even
|
||||
numbered word you have read
|
||||
{/textformat}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
y el script de PHP usando la funci<63>n
|
||||
<ulink url="&url.php-manual;function.mail">mail()</ulink>
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
|
||||
// get contact from database eg using pear or adodb
|
||||
$query = 'select name, email, login_id from contacts where contact_id='.$contact_id;
|
||||
$contact = $db->getRow($sql);
|
||||
$smarty->assign('contact', $contact);
|
||||
|
||||
mail($contact['email'], 'Subject', $smarty->fetch('email_body.tpl'));
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Ver tambi<62>n
|
||||
<link linkend="language.function.fetch">{fetch}</link>
|
||||
<link linkend="api.display">display()</link>,
|
||||
<link linkend="language.function.eval">{eval}</link>,
|
||||
y
|
||||
<link linkend="api.template.exists">template_exists()</link>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
|
||||
<!-- Keep this comment at the end of the file
|
||||
Local variables:
|
||||
mode: sgml
|
||||
|
@@ -2,22 +2,22 @@
|
||||
<!-- $Revision$ -->
|
||||
<refentry id="api.get.config.vars">
|
||||
<refnamediv>
|
||||
<refname>get_config_vars</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refname>get_config_vars()</refname>
|
||||
<refpurpose>retorna el valor asignado a la variable de configuraci<63>n</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
<title>Descripci<EFBFBD>n</title>
|
||||
<methodsynopsis>
|
||||
<type>array</type><methodname>get_config_vars</methodname>
|
||||
<methodparam choice="opt"><type>string</type><parameter>varname</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Este retona el valor de la variable de configuraci<63>n dado.
|
||||
Si no tiene un par<61>metro dado, un arreglo de todas las variables
|
||||
de los archivos de configuraci<63>n es retornado.
|
||||
Si no tiene un par<61>metro asignado, un arreglo de todas las
|
||||
<link linkend="language.config.variables">variables
|
||||
de los archivos de configuraci<63>n</link> es retornado.
|
||||
</para>
|
||||
<example>
|
||||
<title>get_config_vars</title>
|
||||
<title>get_config_vars()</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
@@ -33,6 +33,14 @@ print_r($config_vars);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n
|
||||
<link linkend="api.clear.config">clear_config()</link>,
|
||||
<link linkend="language.function.config.load">{config_load}</link>,
|
||||
<link linkend="api.config.load">config_load()</link>
|
||||
y
|
||||
<link linkend="api.get.template.vars">get_template_vars()</link>.
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -2,22 +2,24 @@
|
||||
<!-- $Revision$ -->
|
||||
<refentry id="api.get.registered.object">
|
||||
<refnamediv>
|
||||
<refname>get_registered_object</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refname>get_registered_object()</refname>
|
||||
<refpurpose>Este retorna una referencia para un objeto registrado.</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
<title>Descripci<EFBFBD>n</title>
|
||||
<methodsynopsis>
|
||||
<type>array</type><methodname>get_registered_object</methodname>
|
||||
<methodparam><type>string</type><parameter>object_name</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Este retorna una referencia para un objeto registrado.
|
||||
Este es <20>til dentro de una funci<63>n habitual cuando usted
|
||||
necesita acesar directamente a un objeto registrado.
|
||||
necesita acesar directamente a un
|
||||
<link linkend="api.register.object">objeto registrado</link>.
|
||||
Ver <link linkend="advanced.features.objects">objects</link> para mas
|
||||
informaci<63>n;
|
||||
</para>
|
||||
<example>
|
||||
<title>get_registered_object</title>
|
||||
<title>get_registered_object()</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
@@ -33,6 +35,13 @@ function smarty_block_foo($params, &$smarty)
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n
|
||||
<link linkend="api.register.object">register_object()</link>,
|
||||
<link linkend="api.unregister.object">unregister_object()</link>
|
||||
y
|
||||
<link linkend="advanced.features.objects">objects section</link>
|
||||
</para>
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -2,19 +2,18 @@
|
||||
<!-- $Revision$ -->
|
||||
<refentry id="api.get.template.vars">
|
||||
<refnamediv>
|
||||
<refname>get_template_vars</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refname>get_template_vars()</refname>
|
||||
<refpurpose>Retorna el valor asignado a una variable</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
<title>descripci<EFBFBD>n</title>
|
||||
<methodsynopsis>
|
||||
<type>array</type><methodname>get_template_vars</methodname>
|
||||
<methodparam choice="opt"><type>string</type><parameter>varname</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Este retorna el valor de una variable asignada. Si no tiene un
|
||||
par<EFBFBD>metro dado, un arreglo de todas las variables asignadas es
|
||||
retornado.
|
||||
Si no tiene un par<61>metro dado, un arreglo de todas las variables
|
||||
<link linkend="api.assign">asignadas</link> es retornado.
|
||||
</para>
|
||||
<example>
|
||||
<title>get_template_vars</title>
|
||||
@@ -33,6 +32,17 @@ print_r($tpl_vars);
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="api.assign">assign()</link>,
|
||||
<link linkend="language.function.assign">{assign}</link>,
|
||||
<link linkend="api.assign.by.ref">assign_by_ref()</link>,
|
||||
<link linkend="api.append">append()</link>,
|
||||
<link linkend="api.clear.assign">clear_assign()</link>,
|
||||
<link linkend="api.clear.all.assign">clear_all_assign()</link>
|
||||
y
|
||||
<link linkend="api.get.config.vars">get_config_vars()</link>
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -2,11 +2,11 @@
|
||||
<!-- $Revision$ -->
|
||||
<refentry id="api.is.cached">
|
||||
<refnamediv>
|
||||
<refname>is_cached</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refname>is_cached()</refname>
|
||||
<refpurpose>Retorna true si hay cache valido para ese template</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
<title>Descripci<EFBFBD>n </title>
|
||||
<methodsynopsis>
|
||||
<type>bool</type><methodname>is_cached</methodname>
|
||||
<methodparam><type>string</type><parameter>template</parameter></methodparam>
|
||||
@@ -14,12 +14,12 @@
|
||||
<methodparam choice="opt"><type>string</type><parameter>compile_id</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Este retorna true si hay un cache valido para ese template.
|
||||
Esto solamente funciona si <link linkend="variable.caching">
|
||||
caching</link> est<73> asignado a true.
|
||||
ver tambi<62>n <link linkend="caching">caching section</link>.
|
||||
</para>
|
||||
<example>
|
||||
<title>is_cached</title>
|
||||
<title>is_cached()</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
@@ -35,9 +35,10 @@ $smarty->display("index.tpl");
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Usted tambi<62>n puede pasar un identificador de cache como un
|
||||
segundo par<61>metro opcional en el caso que usted quiera multiples
|
||||
caches para el template dado.
|
||||
Usted tambi<62>n puede pasar un identificador de $cache como un
|
||||
segundo par<61>metro opcional en el caso que usted quiera
|
||||
<link linkend="caching.multiple.caches">multiples caches</link>
|
||||
para el template dado.
|
||||
</para>
|
||||
<para>
|
||||
Usted puede proporcionar el identidicador como un tercer parametro
|
||||
@@ -45,12 +46,13 @@ $smarty->display("index.tpl");
|
||||
<link linkend="variable.compile.id">$compile_id</link> es usada.
|
||||
</para>
|
||||
<para>
|
||||
Si usted no quiere pasar el identificador de cache solamente
|
||||
quiere pasar el compile id debe pasar <literal>null</literal>
|
||||
Si usted no quiere pasar el
|
||||
<link linkend="variable.compile.id">identificador de cache</link>
|
||||
solamente quiere pasar el compile id debe pasar <literal>null</literal>
|
||||
como el identidficador de cache.
|
||||
</para>
|
||||
<example>
|
||||
<title>is_cached con templates con multiple-cache</title>
|
||||
<title>is_cached() con templates con multiple-cache</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
@@ -83,6 +85,14 @@ $smarty->display("index.tpl", "FrontPage");
|
||||
<literal>is_cached</literal> retorna true.
|
||||
</para>
|
||||
</note>
|
||||
<para>
|
||||
Ver tambi<62>n
|
||||
<link linkend="api.clear.cache">clear_cache()</link>,
|
||||
<link linkend="api.clear.all.cache">clear_all_cache()</link>,
|
||||
y
|
||||
<link linkend="caching">caching section</link>.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -2,18 +2,17 @@
|
||||
<!-- $Revision$ -->
|
||||
<refentry id="api.load.filter">
|
||||
<refnamediv>
|
||||
<refname>load_filter</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refname>load_filter()</refname>
|
||||
<refpurpose>Carga un filtro de plugin</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
<title> Descripci<63>n</title>
|
||||
<methodsynopsis>
|
||||
<type>void</type><methodname>load_filter</methodname>
|
||||
<methodparam><type>string</type><parameter>type</parameter></methodparam>
|
||||
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Esta funci<63>n puede ser usada para cargar un filtro de plugin.
|
||||
El primer argumento especif<69>ca el tipo de filtro a cargar y puede
|
||||
ser uno de los siguientes: 'pre', 'post', o 'output'. El segundo
|
||||
argumento especif<69>ca el nombre del filtro del plugin, por ejemplo,
|
||||
@@ -31,6 +30,16 @@ $smarty->load_filter('output', 'compress'); // load output filter named 'compres
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n
|
||||
<link linkend="api.register.prefilter">register_prefilter()</link>,
|
||||
<link linkend="api.register.postfilter">register_postfilter()</link>,
|
||||
<link linkend="api.register.outputfilter">register_outputfilter()</link>,
|
||||
<link linkend="variable.autoload.filters">$autoload_filters</link>
|
||||
y
|
||||
<link linkend="advanced.features">Advanced features</link>.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -2,11 +2,11 @@
|
||||
<!-- $Revision$ -->
|
||||
<refentry id="api.register.block">
|
||||
<refnamediv>
|
||||
<refname>register_block</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refname>register_block()</refname>
|
||||
<refpurpose>Registra dinamicamente bloques de funciones de plugins </refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
<title>Descripci<EFBFBD>n</title>
|
||||
<methodsynopsis>
|
||||
<type>void</type><methodname>register_block</methodname>
|
||||
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
||||
@@ -38,11 +38,11 @@
|
||||
plugins </link> para saber como usar las propiedades.
|
||||
</para>
|
||||
<example>
|
||||
<title>register_block</title>
|
||||
<title>register_block()</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$smarty->register_block("translate", "do_translation");
|
||||
$smarty->register_block('translate', 'do_translation');
|
||||
|
||||
function do_translation ($params, $content, &$smarty, &$repeat)
|
||||
{
|
||||
@@ -67,6 +67,13 @@ Hello, world!
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Ver tambi<62>n
|
||||
<link linkend="api.unregister.block">unregister_block()</link>
|
||||
y
|
||||
<link linkend="plugins.block.functions">Plugin Block Functions</link>.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -3,10 +3,10 @@
|
||||
<refentry id="api.register.compiler.function">
|
||||
<refnamediv>
|
||||
<refname>register_compiler_function</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refpurpose>Registra dinamicamente un plugin de una funcion compiladora</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
<title>Descripci<EFBFBD>n </title>
|
||||
<methodsynopsis>
|
||||
<type>bool</type><methodname>register_compiler_function</methodname>
|
||||
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
||||
@@ -14,29 +14,41 @@
|
||||
<methodparam><type>bool</type><parameter>cacheable</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Use esto para registrar din<69>micamente una funci<63>n compiladora
|
||||
de plugin. Pase el nombre de la funci<EFBFBD>n compiladora, seguido
|
||||
por la funci<63>n PHP que implemente esto.
|
||||
Pase el nombre de la
|
||||
<link linkend="plugins.compiler.functions">funci<EFBFBD>n compiladora</link>,
|
||||
seguido por la funci<63>n PHP que implemente esto.
|
||||
</para>
|
||||
<para>
|
||||
La llamada a la funcion-php <parameter>impl</parameter> puede ser
|
||||
(a) una cadena conteniendo el nombre de la funci<63>n o
|
||||
(b) un arreglo en el formato
|
||||
<literal>array(&$object, $method)</literal> con
|
||||
<literal>&$object</literal> siendo una referencia para
|
||||
un objeto y <literal>$method</literal> siendo una cadena conteniendo
|
||||
el nombre del m<>todo o
|
||||
(c) un arreglo en el formato
|
||||
<literal>array(&$class, $method)</literal> con
|
||||
<literal>$class</literal> siendo un nombre de
|
||||
clase y <literal>$method</literal> siendo el m<>todo de esta clase.
|
||||
</para>
|
||||
<orderedlist numeration="loweralpha">
|
||||
<listitem>
|
||||
<para>
|
||||
<parameter>cacheable</parameter> puede ser omitido en la mayoria
|
||||
de los casos.
|
||||
a una cadena conteniendo el nombre de la funci<63>n
|
||||
</para>
|
||||
</listitem><listitem>
|
||||
<para>un arreglo con la forma <literal>array(&$object, $method)</literal> con
|
||||
<literal>&$object</literal> siendo una referencia para un objeto y
|
||||
<literal>$method</literal> siendo una cadena conteniendo el nombre del m<>todo
|
||||
</para>
|
||||
</listitem><listitem>
|
||||
<para>un arreglo con la forma
|
||||
<literal>array(&$class, $method)</literal> con
|
||||
<literal>$class</literal> siendo el nombre de una clase y
|
||||
<literal>$method</literal> siendo el m<>todo de esta clase.
|
||||
</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
<para>
|
||||
<parameter>cacheable</parameter> puede ser omitido en la mayoria de los casos.
|
||||
Vea <link linkend="caching.cacheable">Controlando modos de Salida de
|
||||
Cache de los Plugins</link> para obtener mayor informaci<63>n.
|
||||
</para>
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="api.unregister.compiler.function">unregister_compiler_function() </link>
|
||||
y <link linkend="plugins.compiler.functions">Plugin Compiler Functions</link>.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
@@ -2,50 +2,60 @@
|
||||
<!-- $Revision$ -->
|
||||
<refentry id="api.register.function">
|
||||
<refnamediv>
|
||||
<refname>register_function</refname>
|
||||
<refpurpose></refpurpose>
|
||||
<refname>register_function()</refname>
|
||||
<refpurpose>Registra dinamicamente un plugin de funci<63>n para un template</refpurpose>
|
||||
</refnamediv>
|
||||
<refsect1>
|
||||
<title />
|
||||
<title>Descripci<EFBFBD>n</title>
|
||||
<methodsynopsis>
|
||||
<type>void</type><methodname>register_function</methodname>
|
||||
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
||||
<methodparam><type>mixed</type><parameter>impl</parameter></methodparam>
|
||||
<methodparam><type>bool</type><parameter>cacheable</parameter></methodparam>
|
||||
<methodparam><type>mixed</type><parameter>cache_attrs</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>bool</type><parameter>cacheable</parameter></methodparam>
|
||||
<methodparam choice="opt"><type>mixed</type><parameter>cache_attrs</parameter></methodparam>
|
||||
</methodsynopsis>
|
||||
<para>
|
||||
Use este para registrar funciones de plugins din<69>micamente para
|
||||
el template. Pase en el template el nombre de la funci<63>n, seguido
|
||||
Pase en el template el nombre de la funci<63>n, seguido
|
||||
por el nombre de la funci<63>n PHP que implementa esto.
|
||||
</para>
|
||||
<para>
|
||||
La llamada a la funcion-php <parameter>impl</parameter> puede ser
|
||||
(a) una cadena conteniendo el nombre de la funci<63>n o
|
||||
(b) un arreglo en el formato
|
||||
<literal>array(&$object, $method)</literal> con
|
||||
<literal>&$object</literal> siendo una referencia para
|
||||
un objeto y <literal>$method</literal> siendo una cadena
|
||||
conteniendo el nombre del m<>todo o
|
||||
(c) un arreglo en el formato
|
||||
<literal>array(&$class, $method)</literal> con
|
||||
<literal>$class</literal> siendo un nombre de clase y
|
||||
<literal>$method</literal> siendo un m<>todo de esta clase.
|
||||
La llamada a la funcion-php <parameter>impl</parameter> puede ser:
|
||||
</para>
|
||||
<orderedlist numeration="loweralpha">
|
||||
<listitem>
|
||||
<para>
|
||||
<parameter>cacheable</parameter> y <parameter>cache_attrs</parameter>
|
||||
pueden ser omitidos en la mayoria de los casos.
|
||||
a una cadena conteniendo el nombre de la funci<63>n o
|
||||
</para>
|
||||
</listitem><listitem>
|
||||
<para>
|
||||
un arreglo con la forma
|
||||
<literal>array(&$object, $method)</literal> con
|
||||
<literal>&$object</literal> siendo una referencia para un objeto y
|
||||
<literal>$method</literal> siendo una cadena conteniendo el nombre del m<>todo
|
||||
</para>
|
||||
</listitem><listitem>
|
||||
<para>
|
||||
un arreglo con la forma <literal>array(&$class, $method)</literal>
|
||||
con <literal>$class</literal> siendo el nombre de una clase y
|
||||
<literal>$method</literal> siendo un metodo de esa clase.
|
||||
</para>
|
||||
</listitem>
|
||||
</orderedlist>
|
||||
|
||||
<para>
|
||||
<parameter>cacheable</parameter> y <parameter>cache_attrs</parameter> pueden ser omitidos
|
||||
en la mayoria de los caasos.
|
||||
Vea <link linkend="caching.cacheable">Controlando modos de Salida Cache de
|
||||
los Plugins</link> para obtener mayores informes.
|
||||
</para>
|
||||
<example>
|
||||
<title>register_function</title>
|
||||
<title>register_function()</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$smarty->register_function("date_now", "print_current_date");
|
||||
$smarty->register_function('date_now', 'print_current_date');
|
||||
|
||||
function print_current_date($params)
|
||||
function print_current_date($params, &$smarty)
|
||||
{
|
||||
if(empty($params['format'])) {
|
||||
$format = "%b %e, %Y";
|
||||
@@ -54,12 +64,27 @@ function print_current_date($params)
|
||||
return strftime($format,time());
|
||||
}
|
||||
}
|
||||
// ahora usted puede usar eso en el Smarty para mostrar la fecha actual:
|
||||
// {date_now} o, {date_now format="%Y/%m/%d"} para formatearle.
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
y en el template
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{date_now}
|
||||
|
||||
{* or to format differently *}
|
||||
{date_now format="%Y/%m/%d"}
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
Ver tambi<62>n <link linkend="api.unregister.function">unregister_function()</link>
|
||||
y <link linkend="plugins.functions">Plugin functions</link>.
|
||||
</para>
|
||||
|
||||
</refsect1>
|
||||
</refentry>
|
||||
<!-- Keep this comment at the end of the file
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user