mirror of
https://github.com/smarty-php/smarty.git
synced 2025-10-23 17:31:37 +02:00
94 lines
2.7 KiB
XML
94 lines
2.7 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision$ -->
|
|
<refentry id="api.register.block">
|
|
<refnamediv>
|
|
<refname>register_block</refname>
|
|
<refpurpose></refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<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>
|
|
Si può usare questa funzione per registrare dinamicamente
|
|
funzioni plugin per i blocchi. Dovete fornire il nome della
|
|
funzione di blocco, seguito dalla funzione PHP da richiamare
|
|
che implementa tale funzione.
|
|
</para>
|
|
<para>
|
|
Il parametro <parameter>impl</parameter>, contenente la funzione
|
|
callback, può avere uno dei seguenti valori: (a) una stringa
|
|
contenente il nome della funzione (b) un array nella forma
|
|
<literal>array(&$oggetto, $metodo)</literal>, dove
|
|
<literal>&$oggetto</literal> è il riferimento ad un
|
|
oggetto e <literal>$metodo</literal> è una stringa contenente
|
|
il nome di un metodo (c) un array nella forma
|
|
<literal>array(&$classe, $metodo)</literal> dove
|
|
<literal>$classe</literal> è un nome di classe e
|
|
<literal>$metodo</literal> è un metodo statico della
|
|
classe.
|
|
</para>
|
|
<para>
|
|
<parameter>cacheable</parameter> e <parameter>cache_attrs</parameter>
|
|
possono essere omessi nella maggioranza dei casi. Consultate
|
|
<link linkend="caching.cacheable">Controllo della Cache per l'output dei Plugins</link>
|
|
per capire come usarli.
|
|
</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'];
|
|
// faccio la traduzione di $content
|
|
return $translation;
|
|
}
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
<para>
|
|
dove il template è:
|
|
</para>
|
|
<programlisting>
|
|
<![CDATA[
|
|
{* template *}
|
|
{translate lang="br"}
|
|
Hello, world!
|
|
{/translate}
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</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
|
|
-->
|