mirror of
				https://github.com/smarty-php/smarty.git
				synced 2025-11-03 22:01:36 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			99 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
			
		
		
	
	
			99 lines
		
	
	
		
			2.9 KiB
		
	
	
	
		
			XML
		
	
	
	
	
	
<?xml version="1.0" encoding="iso-8859-1"?>
 | 
						|
<!-- $Revision$ -->
 | 
						|
<refentry id="api.register.block">
 | 
						|
 <refnamediv>
 | 
						|
  <refname>register_block()</refname>
 | 
						|
  <refpurpose>Registra dinamicamente bloques de funciones de plugins </refpurpose>
 | 
						|
 </refnamediv>
 | 
						|
 <refsect1>
 | 
						|
  <title>Descripción</title>
 | 
						|
  <methodsynopsis>
 | 
						|
   <type>void</type><methodname>register_block</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>
 | 
						|
  </methodsynopsis>
 | 
						|
  <para>
 | 
						|
   Use este para registrar dinámicamente bloques de funciones de 
 | 
						|
   plugins. Pase el bloque de nombres de función, seguido por una 
 | 
						|
   llamada de función PHP que implemente esto.
 | 
						|
  </para>
 | 
						|
  <para>
 | 
						|
   La llamada de una funcion-php <parameter>impl</parameter>
 | 
						|
   puede ser cualquier (a) cadena conteniendo el nombre de la 
 | 
						|
   función o (b) un arreglo con el formato 
 | 
						|
   <literal>array(&$object, $method)</literal> con
 | 
						|
   <literal>&$object</literal> siendo la referencia a un 
 | 
						|
   objeto y <literal>$method</literal> siendo una cadena
 | 
						|
   conteniendo el nombre del método o (c) un arreglo con 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.
 | 
						|
  </para>
 | 
						|
  <para>
 | 
						|
   <parameter>cacheable</parameter> y <parameter>cache_attrs</parameter>
 | 
						|
   pueden ser omitidos en la mayoria de los casos. Vea <link
 | 
						|
   linkend="caching.cacheable">Controlando modos de salida de cache de los
 | 
						|
   plugins </link> para saber como usar las propiedades.
 | 
						|
  </para>
 | 
						|
  <example>
 | 
						|
   <title>register_block()</title>
 | 
						|
   <programlisting role="php">
 | 
						|
<![CDATA[
 | 
						|
<?php
 | 
						|
$smarty->register_block('translate', 'do_translation');
 | 
						|
 | 
						|
function do_translation ($params, $content, &$smarty, &$repeat) 
 | 
						|
{
 | 
						|
  if (isset($content)) {
 | 
						|
    $lang = $params['lang'];
 | 
						|
    // do some translation with $content
 | 
						|
    return $translation;
 | 
						|
  }
 | 
						|
}
 | 
						|
?>
 | 
						|
]]>
 | 
						|
   </programlisting>
 | 
						|
   <para>
 | 
						|
    Donde el template es:
 | 
						|
   </para>
 | 
						|
   <programlisting>
 | 
						|
<![CDATA[
 | 
						|
{* template *}
 | 
						|
{translate lang="br"}
 | 
						|
Hello, world!
 | 
						|
{/translate}
 | 
						|
]]>
 | 
						|
   </programlisting>
 | 
						|
  </example>
 | 
						|
    <para>
 | 
						|
    Ver tambié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
 | 
						|
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
 | 
						|
-->
 |