| 
									
										
										
										
											2004-10-07 18:50:52 +00:00
										 |  |  |  | <?xml version="1.0" encoding="iso-8859-1"?> | 
					
						
							|  |  |  |  | <!-- $Revision$ --> | 
					
						
							|  |  |  |  | <refentry id="api.assign"> | 
					
						
							|  |  |  |  |  <refnamediv> | 
					
						
							| 
									
										
										
										
											2005-11-08 23:37:29 +00:00
										 |  |  |  |   <refname>assign()</refname> | 
					
						
							|  |  |  |  |   <refpurpose>pasando valores para el template</refpurpose> | 
					
						
							| 
									
										
										
										
											2004-10-07 18:50:52 +00:00
										 |  |  |  |  </refnamediv> | 
					
						
							|  |  |  |  |  <refsect1> | 
					
						
							| 
									
										
										
										
											2005-11-08 23:37:29 +00:00
										 |  |  |  |   <title>Descripci<EFBFBD>n</title> | 
					
						
							| 
									
										
										
										
											2004-10-07 18:50:52 +00:00
										 |  |  |  |   <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> | 
					
						
							| 
									
										
										
										
											2005-11-08 23:37:29 +00:00
										 |  |  |  |    Usted puede explicitamente pasar pares de nombres/valores, o un arreglo  | 
					
						
							| 
									
										
										
										
											2004-10-07 18:50:52 +00:00
										 |  |  |  |    asociativo conteniendo el par de nombre/valor. | 
					
						
							|  |  |  |  |   </para> | 
					
						
							|  |  |  |  |   <example> | 
					
						
							| 
									
										
										
										
											2005-11-08 23:37:29 +00:00
										 |  |  |  |    <title>assign()</title> | 
					
						
							|  |  |  |  | <programlisting role="php"> | 
					
						
							| 
									
										
										
										
											2004-10-07 18:50:52 +00:00
										 |  |  |  | <![CDATA[ | 
					
						
							|  |  |  |  | <?php | 
					
						
							| 
									
										
										
										
											2005-11-08 23:37:29 +00:00
										 |  |  |  | // pasando pares de nombre/valor  | 
					
						
							| 
									
										
										
										
											2004-10-07 18:50:52 +00:00
										 |  |  |  | $smarty->assign('Name', 'Fred'); | 
					
						
							|  |  |  |  | $smarty->assign('Address', $address); | 
					
						
							|  |  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2005-11-08 23:37:29 +00:00
										 |  |  |  | // 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} | 
					
						
							| 
									
										
										
										
											2004-10-07 18:50:52 +00:00
										 |  |  |  | ?> | 
					
						
							|  |  |  |  | ]]> | 
					
						
							| 
									
										
										
										
											2005-11-08 23:37:29 +00:00
										 |  |  |  | </programlisting> | 
					
						
							| 
									
										
										
										
											2004-10-07 18:50:52 +00:00
										 |  |  |  |   </example> | 
					
						
							| 
									
										
										
										
											2005-11-08 23:37:29 +00:00
										 |  |  |  |   <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> | 
					
						
							| 
									
										
										
										
											2004-10-07 18:50:52 +00:00
										 |  |  |  |  </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 | 
					
						
							|  |  |  |  | --> |