Re: [SMARTY-DEV] Block extensibility?
| From: | messju mohr | Date: | Wed, 26 Mar 2003 11:32:59 +0000 |
| Subject: | Re: [SMARTY-DEV] Block extensibility? | ||
| References: | 1 | Groups: | php.smarty.dev |
| Request: | Send a blank email to php-smarty-dev+get-1027@lists.php.net to get a copy of this message | ||
On Wed, Mar 26, 2003 at 12:05:52PM +0100, Nico Sabbi wrote:
> Hello,
>
> I'm considering Smarty as an alternative to a custom language (developed internally) to
> use embedded in html pages.
> For this purpose I need to provide at least the same functionalities as the existing ones, and
> a requisite for this is the possibility
> to write external commands in the form of short tags AND n-ary block tags.
>
> Reading the manual I found a section describing how to extend Smarty with functions that can be
> used in block context;
> reading the mailing-list I found a patch (that seems to apply to Smarty1) that should permit to
> write block
> which have n-components (such as {if} {else} {/if} ).
>
> My questions are:
>
> is this last patch embedded in / valid for Smarty2 ?
i don't know which one you mean, but i'm pretty sure it is not anyway.
> In this case, can I write blocks such as the following one?
> {if}
> {elsif}* repeated an unlimited (and not know a-priori) number of times
> {else}
> {/if}
blocks in smarty a very restricted. for something like the above you
would have to use your own compiler functions. see:
http://smarty.php.net/manual/en/plugins.compiler.functions.php
(hint) maybe you don't need to patch smarty, since you can:
register_compiler_function('myif', 'myif_open);
register_compiler_function('/myif', 'myif_close);
then you can implement a closing and an opening function (and
optionallyy my_else etc., of course) and write in your template:
{myif ...} ... {/myif}
> Where can I find some in depth examples of block extensions?
>
>
> Thanks in advance,
>
>
> Nico Sabbi