|
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 |
mitke013 Smarty n00b
Joined: 11 Aug 2011 Posts: 3
|
Posted: Wed Feb 01, 2012 8:49 pm Post subject: Template inheritance: check if {block name="tabs"} |
|
|
Is there a way to check if parent.tpl knows if any of child templates has a block called ie.tabs?
Example:
....
parent.tpl
<div class="{if $smarty->hasBlockInChildren('tabs')} with-tabs{/if}">
child.tpl
{extends file="parent.tpl"}
{block name="tabs"}
...some content
{/block}
The above usage is just an example. I searched thru all the docs and can't find if it is possible.
Thanks. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Thu Feb 02, 2012 6:52 am Post subject: |
|
|
There is no way to check it by an {if} condition but you could do the following
parent.tpl
Code: | <div class="{block name="tabs_class"}{/block}"> |
child.tpl
Code: | {block name="tabs_class"}with-tabs{/block}
{block name="tabs"}
...some content
{/block} |
|
|
Back to top |
|
mitke013 Smarty n00b
Joined: 11 Aug 2011 Posts: 3
|
Posted: Fri Feb 03, 2012 7:56 pm Post subject: |
|
|
Thanks, I have been using similar code before, just wanted to make it more simple (ie. avoid another block).
I really hope such feature will appear in future versions. It can become very handy when there are 3+ inherited files. |
|
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
|