2004-04-13 11:47:32 +00:00
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
|
|
|
<!-- $Revision$ -->
|
2004-04-18 19:22:55 +00:00
|
|
|
<refentry id="api.register.block">
|
|
|
|
|
<refnamediv>
|
2005-05-27 16:25:02 +00:00
|
|
|
<refname>register_block()</refname>
|
|
|
|
|
<refpurpose>dynamically register block functions plugins</refpurpose>
|
2004-04-18 19:22:55 +00:00
|
|
|
</refnamediv>
|
|
|
|
|
<refsect1>
|
2005-05-27 16:25:02 +00:00
|
|
|
<title>Description</title>
|
2004-04-18 19:22:55 +00:00
|
|
|
<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>
|
2006-09-26 23:29:02 +00:00
|
|
|
|
2004-04-18 19:22:55 +00:00
|
|
|
<para>
|
2005-05-27 16:25:02 +00:00
|
|
|
Use this to dynamically register
|
2006-09-26 23:29:02 +00:00
|
|
|
<link linkend="plugins.block.functions">block function plugins</link>.
|
|
|
|
|
Pass in the block function <parameter>name</parameter>, followed by the PHP
|
|
|
|
|
function's name that implements it.
|
2004-04-18 19:22:55 +00:00
|
|
|
</para>
|
2006-09-26 23:29:02 +00:00
|
|
|
&api.register.snippet;
|
|
|
|
|
|
2004-04-18 19:22:55 +00:00
|
|
|
<para>
|
|
|
|
|
<parameter>cacheable</parameter> and <parameter>cache_attrs</parameter>
|
2005-05-27 16:25:02 +00:00
|
|
|
can be omitted in most cases. See <link
|
2006-09-26 23:29:02 +00:00
|
|
|
linkend="caching.cacheable">controlling cacheability of plugins' output</link>
|
|
|
|
|
section on how to implement them properly.
|
2004-04-18 19:22:55 +00:00
|
|
|
</para>
|
|
|
|
|
<example>
|
2005-05-27 16:25:02 +00:00
|
|
|
<title>register_block()</title>
|
2004-04-18 19:22:55 +00:00
|
|
|
<programlisting role="php">
|
2004-04-13 11:47:32 +00:00
|
|
|
<![CDATA[
|
|
|
|
|
<?php
|
2006-09-26 23:29:02 +00:00
|
|
|
// function declaration
|
2005-05-27 16:25:02 +00:00
|
|
|
function do_translation ($params, $content, &$smarty, &$repeat)
|
2004-04-18 19:22:55 +00:00
|
|
|
{
|
|
|
|
|
if (isset($content)) {
|
|
|
|
|
$lang = $params['lang'];
|
|
|
|
|
// do some translation with $content
|
|
|
|
|
return $translation;
|
|
|
|
|
}
|
2004-04-13 11:47:32 +00:00
|
|
|
}
|
2006-09-26 23:29:02 +00:00
|
|
|
|
|
|
|
|
// register with smarty
|
|
|
|
|
$smarty->register_block('translate', 'do_translation');
|
2004-04-13 11:47:32 +00:00
|
|
|
?>
|
2004-05-29 21:22:39 +00:00
|
|
|
]]>
|
|
|
|
|
</programlisting>
|
|
|
|
|
<para>
|
2006-09-26 23:29:02 +00:00
|
|
|
Where the template is:
|
2004-05-29 21:22:39 +00:00
|
|
|
</para>
|
|
|
|
|
<programlisting>
|
|
|
|
|
<![CDATA[
|
2006-09-26 23:29:02 +00:00
|
|
|
{translate lang='br'}Hello, world!{/translate}
|
2004-04-13 11:47:32 +00:00
|
|
|
]]>
|
2004-04-18 19:22:55 +00:00
|
|
|
</programlisting>
|
|
|
|
|
</example>
|
2005-05-27 16:25:02 +00:00
|
|
|
|
|
|
|
|
<para>
|
|
|
|
|
See also
|
2006-09-26 23:29:02 +00:00
|
|
|
<link linkend="api.unregister.block"><varname>unregister_block()</varname></link>
|
|
|
|
|
and the
|
|
|
|
|
<link linkend="plugins.block.functions">plugin block functions</link> page.
|
2005-05-27 16:25:02 +00:00
|
|
|
</para>
|
|
|
|
|
|
2004-04-18 19:22:55 +00:00
|
|
|
</refsect1>
|
|
|
|
|
</refentry>
|
2004-04-13 11:47:32 +00:00
|
|
|
<!-- 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
|
2004-04-18 19:22:55 +00:00
|
|
|
-->
|