Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

$smarty.block.parent doesn't work in 3.1.27 and HEAD #68

Closed
chilek opened this issue Jul 5, 2015 · 5 comments
Closed

$smarty.block.parent doesn't work in 3.1.27 and HEAD #68

chilek opened this issue Jul 5, 2015 · 5 comments

Comments

@chilek
Copy link

chilek commented Jul 5, 2015

As in summary. I tried to insert {$smarty.block.parent} in block modified by child template but without effect.
Btw. http://www.smarty.net/docs/en/language.function.block.tpl contains inproper examples of prepend and append flag usage. These flags are used in reversed meaning.

@uwetews
Copy link
Contributor

uwetews commented Aug 23, 2015

Can you provide an example? I can't reproduce it right now

@chilek
Copy link
Author

chilek commented Aug 23, 2015

Yes of course!

  1. Create parent template and save it as file named layout.html:
<html>

<head>
</head>

<body>

{block name="header"}
header
{/block}

{block name="content"}
{/block}

{block name="footer"}
footer
{/block}

</body>

</html>
  1. Create child template and save it in file named module.html:
{extends file="layout.html"}
{block name="content"}
  {block name="module-content"}
  content
  {/block}
{/block}
  1. Create grandchild template and save it in file named info.html:
{extends file="module.html"}
{block name="header"}
  <p style="text-align:center">header-grandchild1</p>
  {$smarty.block.parent}
  <p style="text-align:center">header-grandchild2</p>
{/block}
{block name="module-content"}
  <p style="text-align:center">content-grandchild1</p>
  {$smarty.block.parent}
  <p style="text-align:center">content-grandchild2</p>
{/block}
{block name="footer"}
  <p style="text-align:center">footer-grandchild1</p>
  {$smarty.block.parent}
  <p style="text-align:center">footer-grandchild2</p>
{/block}

In header you will see:

header-grandchild1
header
header-grandchild2

In footer you will see:

footer-grandchild1
footer
footer-grandchild2

But in module-content you will see:

content-grandchild1
content-grandchild2

Expected result by me was:

content-grandchild1
content
content-grandchild2

@uwetews
Copy link
Contributor

uwetews commented Aug 23, 2015

Your example does not output 'header' and 'footer' but anyway the {$smarty.block.parent} does reference the the content block in layout.html. That is really not very help full.
Let me see what I can do.

@chilek
Copy link
Author

chilek commented Aug 23, 2015

Yes, I missed header and footer content in layout.html file, so I fixed it before the moment.

uwetews added a commit that referenced this issue Sep 1, 2015
  - bugfix {$smarty.block.parent} did always reference the root parent block #68
uwetews added a commit that referenced this issue Sep 1, 2015
  - bugfix {$smarty.block.parent} did always reference the root parent block #68
@uwetews
Copy link
Contributor

uwetews commented Sep 1, 2015

Your problem is now fixed in the master branch.
Also template inheritance is now a run time process. All previous existing restrictions should no longer apply.

@uwetews uwetews closed this as completed Sep 1, 2015
think-mcunanan pushed a commit to think-mcunanan/smarty that referenced this issue Mar 22, 2023
Merge release-2.0.7.2 into release-2.0.8 branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants