Hi Tarjei,
On Wed, 31 Oct 2001 00:10:25 +0100
"Tarjei Huse" <[EMAIL PROTECTED]> wrote:
> ok,
>
> I've uploaded the annontations from the old manual. Here are some comments:
>
> 1. The User Defined Filter/Formater function (UDF) by David Guerizec
> Do you have some writeup on this function David? Also, I added it to funcref for
> now. It should probably be moved quite soon, but I didn't whant to loose it.
I remember I did write something about it but cannot find it anymore...
Anyway, a quick glance at the source remembered how it works:
mgd_register_filter($name, [$function])
- if $name and $function are not empty, it will register the function $function with
the filter name $name
- if $function is present but empty (""), it will unregister the function associated
with the filter name $name
- if only the $name parameter is present, it will return the name of the registered
function with that filter name.
Example of use:
<?
function my_news_filter($obj) {
echo "<h1>$obj->title</h1>\n";
echo "<p>$obj->abstract</p>\n";
echo "<p>$obj->content</p>\n";
}
mgd_register_function("article", "my_news_filter"); // registers the filter func
$article = mgd_get_article($argv[0]);
?>&(article:xnews);<? // the x prefix is necessary to identify the filter name
echo mgd_register_filter("article"); // prints "my_news_filter"
mgd_register_filter("article", ""); // unregisters the filter func
echo mgd_register_filter("article"); // prints nothing
?>
Of course, this is a simple one, and instead of passing the article object, you can
pass any PHP variable, provided the filter function is able to understand its
parameter.
Hope that helps,
David
> Tarjei
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]