Re: knowing your template
"messju mohr" <[email protected]> Tue, 13 Dec 2005 00:02:51 +0100
| Newsgroups | gmane.comp.php.smarty.devel |
|---|---|
| Message-ID | <20051212230251.GB15899@dune> |
On Mon, Dec 12, 2005 at 11:27:12PM +0100, [email protected] wrote: > boots wrote: > >No, unfortuantely there is not. If you are in a compiler function (or a > >prefilter) you can access a private member, $compiler->_current_file -- > >which is the fullpath to the actual template file -- but if you want to > >use it after compile time, you will need to insert a corresponding > >assignment into the template code. There shouldn't be a problem with > >nesting as scope is restored after an include is completed. > > Is there a plan for this in 3.0 or so? You can automate that very easy. write a prefilter that prepends '{assign var=current_template value=$smarty.template}' to each source. you can access $smarty->get_template_vars('current_template') inside your plugins then. and smarty does the bookkeeping of nesting automagically since it restores the old value of $current_template when the template is left (you cannot change vars of including templates inside included template) have fun messju -- Smarty Development Mailing List (http://smarty.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php