Re: [PHP Template] Need opinions on @section/var
[email protected] (Monte Ohrt) Fri, 17 Mar 2000 10:16:21 -0600
| Newsgroups | php.template |
|---|---|
| Organization | ispi |
| Message-ID | <[email protected]> |
Andrei Zmievski wrote:
>
> I need help and opinions on how @section/var (and #section/var) syntax
> should function. As a reminder, it refers to the value of a variable as
> it exists in another section.
>
> Now, the problem is this. It is not possible during parsing time to
> resolve whether the section name specified by the construct exists. The
> validation can be done only after the whole template is parsed. However,
> several issues come into play.
>
> 1) What if there are no sections with that name? Obviously, it should
> output some sort of error, but I think it should not abandon execution
> and should instead treat @section/var simply as @var.
I'm not sure I would give it @var, maybe leave the value unset.
>
> 2) What if there is more than one section with that name? Which one
> should it use? The first one?
Maybe the most recently executed section?
>
> 3) Would it ever be useful for this construct to have forward
> references, i.e. you use @sec2/var and 'sec2' is 40 lines down the page?
I can't think of many good uses of this. Would this have a parsing
overhead?
>
> 4) Another option is when @section/var is encountered at parsing time it
> would check only those sections that have been defined so far to see
> whether the name is there. This does not allow forward references, but,
> like I said, it might not be useful.
>
> Another issue I wanted to mention is that #TOTAL is going to be valid
> only inside the section and after it. Example:
>
> { section sec1 }
> Category: $category
> { section sec2 }
> Headline: $headline
> { /section }
> { /section }
>
> The #TOTAL for sec2 is going to be undefined the first time Category is
> printed. It will be calculated only when we enter sec2 and also after
> it, the second time Category is printed. Basically, #TOTAL is calculated
> each time you enter the section and it's persistent afterwards until the
> next time. I hope it's not an inconvenience.
That sounds logical.