|
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 |
geoB Smarty Regular
Joined: 09 Sep 2010 Posts: 46
|
Posted: Sun Jul 22, 2012 11:37 pm Post subject: Inherited template and $smarty.template |
|
|
It appears that inside a template returns the name of the outermost template rather than the name of the template containing that code.
For example, index.tpl contains: Code: | {extends file="search_form.tpl"} | and search_form.tpl contains: Code: |
{extends file="layout.tpl"}
{assign value=$smarty.template|replace:'.tpl':'' var='formName'}
...
<input type="hidden" name="formName" value="{$formName}">
|
When the source of index.php is viewed, one sees that formName=index.
Is this by design or otherwise unavoidable?
Thanks.
George |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Mon Jul 23, 2012 6:38 pm Post subject: |
|
|
Template inheritance is a compile time process where the source blocks of child and parent are replaced/merged together in one compiled template file.
{$smarty.template} will return always the name of the compiled template file which is in your case 'index.tpl'.
But why can't you just assign the string 'search_form' to variable $formName? |
|
Back to top |
|
geoB Smarty Regular
Joined: 09 Sep 2010 Posts: 46
|
Posted: Thu Jul 26, 2012 8:50 pm Post subject: |
|
|
Thanks for your reply. That's what I ended up doing, figuring the explanation was most likely what you provided. Guess I was just trying to be too clever.
George |
|
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
|