Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.
Template inheritance: check if {block name="tabs"}

 
Post new topic   Reply to topic    Smarty Forum Index -> Feature Requests
View previous topic :: View next topic  
Author Message
mitke013
Smarty n00b


Joined: 11 Aug 2011
Posts: 3

PostPosted: Wed Feb 01, 2012 8:49 pm    Post subject: Template inheritance: check if {block name="tabs"} Reply with quote

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
View user's profile Send private message
U.Tews
Administrator


Joined: 22 Nov 2006
Posts: 4631
Location: Hamburg / Germany

PostPosted: Thu Feb 02, 2012 6:52 am    Post subject: Reply with quote

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
View user's profile Send private message
mitke013
Smarty n00b


Joined: 11 Aug 2011
Posts: 3

PostPosted: Fri Feb 03, 2012 7:56 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Feature Requests All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP