|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
teo13 Smarty n00b
Joined: 18 Jun 2014 Posts: 1
|
Posted: Wed Jun 18, 2014 12:52 pm Post subject: Inheritance after 3.1.14 |
|
|
First, i want to thank you for your work, i am using smarty many years and still happy with it.
I've noticed some inheritance change after 3.1.14. "Children" template files cant access blocks, wich were defined in parents.
Here is an example:
layout.tpl:
Code: | {block name="main"}{/block} |
default.tpl:
Code: |
{extends file="layout.tpl"}
{block name="some"}
some block
{/block}
|
index.tpl:
Code: |
{extends file="default.tpl"}
{block name="main"}
Some block:
{block name="some"}{/block}
{/block}
|
So after display the index.tpl in 3.1.14 i have a desired result:
"Some block: some block"
In 3.1.18 (3.1.16 or 15+) block "some" is not seen in child template anymore and i have a:
"Some block: "
It was some sort of hack, that it works before, or else?
What will be in future changes?
Thank you. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Wed Jun 18, 2014 4:51 pm Post subject: |
|
|
The old solution had a lot of ambiguousness depending on template structures and {block} nesting levels.
With {$smarty.block.parent} you can access the parent block.
But there is the restriction that {$smarty.block.parent} does always use the block name of the outermost of the child to look for the parent block.
See also http://www.smarty.net/docs/en/language.function.block.tpl |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|