Default tag handler -> plugin
| From: | Anders Janson | Date: | Tue, 25 Sep 2001 08:17:14 +0000 |
| Subject: | Default tag handler -> plugin | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-1542@lists.php.net to get a copy of this message | ||
Ivo Jansch wrote:
> Hi,
>
> Andrei Zmievski wrote:
>
> > I'm not against it, but could you first give me an idea of how this is
> > useful?
>
> 1) You could write a function that handles the error gracefully without
> stopping the rendering of the rest of the page.
In real life, it would be very difficult. Write {sectoin} instead of
{section}, and your whole page will look like sh** :)
And there WILL be other interesting side effects ;-)
> Or, inside the default
> handler, you could mail the author of that specific page (which is
> always in my template vars, and which could be accessed using the
> $smarty object that gets passed to the function).
Isn't the author the same guy who just wrote that crappy tag??? Or do you
mean that somebody else tries to update a page (writing crap)?
>
>
> 2) I have an application that allows very easy creation of new
> modifiers, by just defining a function for it.
Ah! Plugin functionality? Yummy... :)
> It's a bit nasty to loop
> through all my files and for all modifiers that exist, register them
> with smarty, so they can be used.
I wrote a plugin class hack a while ago that does exactly this. Nasty,
indeed. A lot of bloated code, just because I need to register the
functions :(
> No, rather I implement the default
> modifier, somewhat like this:
>
> function default_tag_handler($tag, $args, $smartyobj)
> {
> $funcname = $tag."_parse";
> if (function_exists($funcname)) $funcname($args, $smartyobj);
> }
The default handler should also return a boolean to tell if it could handle
the tag/modifier/etc. True=handled it.
Oh, well, just a thought... :)
>
>
> And I'm sure there are other uses as well.
Since this looks like plugin functionality, I'm sure others are interested.
At least I am.
/Anders