My code is as follows:
content.tpl:
{* Smarty *}
{extends file='PageContentLayout.tpl'}
PageContentLayout.tpl
{* Smarty *}
{block name="file_name"}
<p>{$smarty.current_dir}</p>
<p>{$smarty.template}</p>
{/block}
{block name="other_content"}
...
{* blah... *}
...
{/block}
In earlier versions of smarty, this code would print the template name and path of the file: content.tpl
.
However, I've just upgraded to 3.1.29, and it now seems that it's the name of the base file PageContentLayout.tpl
that is being printed.
I assume that this is a deliberate design change in different versions of Smarty, but I can't find any documentation on these changes.
What I'd really like to know though, is what the best way to achieving the former functionality is?
== EDIT ==
I've noticed that even when calling {$smarty.current_dir}
from the extending file, we still get the base-file's path and filename. This is quite a significant change from earlier versions, and quite serious in my case, because I can no longer write dynamic code to find the top-level file's path.
This is probably result of latest change in smarty
Starting with version 3.1.28 template inheritance is no longer a compile time process.
All {block} tag parent/child relations are resolved at run time.
This does resolve all known existing restrictions (see below).
From smarty devs:
Versions < 3.1.28
did cache all template objects for performance to reuse them in case a sub-template was called several times. However it was a wasted of memory.
3.1.28 is optimized for size and speed and the internal template object handling is completely different.
The $smarty->template_objects
was removed.
When debugging is enabled some information like the template file path is can be found within the $smarty->_debug->template_data
array.
Inheritance release notes: https://github.com/smarty-php/smarty/blob/master/INHERITANCE_RELEASE_NOTES.txt
New features: https://github.com/smarty-php/smarty/blob/master/NEW_FEATURES.txt
You can check if $smarty.template_object
don't have data what you need.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With