Home > Archive > PHP Smarty Templates > June 2005 > [SMARTY] Getting information about the template name
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
[SMARTY] Getting information about the template name
|
|
| Erik Schmitt 2005-06-06, 3:59 am |
| Hello,
I would like to access the name of current template
directly from the Smarty-object (inside my own BLOCK-function).
Is this possible? I searched the documentation but
found only {$smarty.template}, which does not help me.
Thanks,
Erik
| |
| Cal Henderson 2005-06-06, 8:58 am |
| Erik Schmitt wrote:
: I would like to access the name of current template
: directly from the Smarty-object (inside my own
BLOCK-function).
: Is this possible? I searched the documentation but
: found only {$smarty.template}, which does not help me.
a quick print_r reveals it's stashed in the smarty
object. try a function like this:
function myfunc($args, $smarty){
$tmpl = $smarty->_plugins['function']['myfunc'][1];
...
}
$smarty->register_function('myfunc', 'myfunc');
but that doesn't work for included templates. to get
the template name inside includes you'll need to patch
your Smarty.class.php file with the patch here:
http://code.iamcal.com/php/smarty/c...mplate/diff.txt
then you can access it like this:
function myfunc($args, $smarty){
$tmpl = $smarty->current_template();
...
}
--cal
|
|
|
|
|