mirror of
https://github.com/smarty-php/smarty.git
synced 2025-10-20 16:05:20 +02:00
93 lines
2.4 KiB
XML
93 lines
2.4 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision$ -->
|
|
<refentry id="api.assign">
|
|
<refnamediv>
|
|
<refname>assign()</refname>
|
|
<refpurpose>pasando valores para el template</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Descripción</title>
|
|
<methodsynopsis>
|
|
<type>void</type><methodname>assign</methodname>
|
|
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<methodsynopsis>
|
|
<type>void</type><methodname>assign</methodname>
|
|
<methodparam><type>string</type><parameter>varname</parameter></methodparam>
|
|
<methodparam><type>mixed</type><parameter>var</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Usted puede explicitamente pasar pares de nombres/valores, o un arreglo
|
|
asociativo conteniendo el par de nombre/valor.
|
|
</para>
|
|
<example>
|
|
<title>assign()</title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// pasando pares de nombre/valor
|
|
$smarty->assign('Name', 'Fred');
|
|
$smarty->assign('Address', $address);
|
|
|
|
// 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é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
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"../../../../manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|