Re: [SMARTY-DEV] Re: object support
| From: | Jan Rosier | Date: | Thu, 23 Jan 2003 09:23:31 +0000 |
| Subject: | Re: [SMARTY-DEV] Re: object support | ||
| References: | 1 2 3 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-602@lists.php.net to get a copy of this message | ||
Hello Monte,
I like this idea of having an standard mode and an advanced mode. In
standard mode the different parts get assign in bits and pieces which does
give maximum controle and an pre defined space ( sandbox ;-) ) to play in
for the template designer.
If you don't need all the controles. You can go for the advanced mode. Which
makes it possible to assign the hole thing at once and give / have access to
the hole playground, but it also makes change of having an accident bigger
:-)
Greetings,
Jan Rosier
> So what if we support both methods? The preferred method of using
> objects will be to register them and use them like regular template
> function calls. This has several limitations, but will probably work
> fine for typical use, and _especially_ those of us who have to train and
> support a diverse field of template designers. OTOH, If you want to
> access an object directly in the template, Smarty will recognize and
> support that as well. Supporting OO syntax in the template is not a
> technical barrier, the whole issue is requiring a new syntax for the
> HTML designers to understand just so we can support object access.
>
> So two ways to use objects:
>
> PREFERRED, PREACHED METHOD:
> 1) Registering of object methods as template functions:
>
> php code:
> $smarty->register_function('themeFoo', array(&$theme, 'foo'));
>
> template:
> {themeFoo p1="foo" p2="bar"}
>
>
> NOT PREFERRED, BUT SUPPORTED METHOD:
> 2) assign objects, access them directly:
>
> php code:
> $smarty->assign_by_ref('theme',$theme);
>
> template:
> {$theme->foo("foo","bar")}
>
>
> It will be clearly stated in the manual the difference between the two
> methods, why use one over the other, etc. We already have issues like
> this in Smarty, where there is nothing stopping you from mixing PHP code
> in the templates but it is highly discouraged, so this really wouldn't
> be any different.
>
> Would this satisfy both sides of the fence?
>
> Monte
>