Re: Smarty feature proposal: context aware template tags
| From: | Anders Janson | Date: | Wed, 28 Nov 2001 12:02:17 +0000 |
| Subject: | Re: Smarty feature proposal: context aware template tags | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-2072@lists.php.net to get a copy of this message | ||
Ivo Jansch wrote:
> Hello,
>
> Anders Janson wrote:
>
> > the tag. The section tag perhaps being the best example, but I still wonder
> > why you would need to know this? Could you give a real-life example of a
> > situation where this would be useful ?
>
> We have a comments system where you can put user comments on a page
> (like the online PHP manual) for example by putting a {comments} tag in
> a template. This renders a comment.tpl for each comment, which in turn
> can contain a {comments} tag to render the subcomments, and so on.
>
> If I have this stack, I can use this information to determine which
> subcomments to render, how much to indent the comments etc. (Our current
> solution contains some static and global vars to accomplish the same,
> but that's a bit dirty)
Ah, I see! Yes, this could be a situation where a tag stack might help. But
isn't a static recursion depth counter variable the usual way to handle this?
Sounds to me like that's what you have today (in the comment tag handler ?), and
I see no reason to call that a dirty solution.
Well, I have not seen you code, so... you'll decide if it's dirty or not :-)
/Anders