register_block() for objects?
| From: | Bharat Mediratta | Date: | Tue, 25 Feb 2003 06:53:39 +0000 |
| Subject: | register_block() for objects? | ||
| Groups: | php.smarty.dev | ||
| Request: | Send a blank email to php-smarty-dev+get-844@lists.php.net to get a copy of this message | ||
Hi all. In looking through the new OO code, it looks like there's
no support for registering a block method for an object callback.
Did I miss something? I want to be able to say:
/* PHP */
class Foo {
function do_translation ($params, $content, &$smarty) {
if ($content) {
$lang = $params['lang'];
// do some translation with $content
echo $translation;
}
}
}
$foo = new Foo();
$smarty->register_object("foo", $foo);
{* template *}
{$foo->translate lang="br"}
Hello, world!
{/$foo->translate}
As I need this functionality, I'm probably going to hack away on
the Smarty code sometime over the next day or so. I'd rather not
do that if it's already been done :-) Thanks.
-Bharat