|
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 |
intuz Smarty n00b
Joined: 22 May 2015 Posts: 3
|
Posted: Fri May 22, 2015 7:03 am Post subject: Smarty Template 3.1 ERROR: variable template file names not |
|
|
these days I am trying to improve my templates by using the Smarty template engine and its OOP template tag {block}
Its working pretty good, but I also noticed when I use {block} - tags the {include file="[...]" variableX="[..]"} breaks when I use nested variables.
PHP Fatal error: [...] variable template file names not allow within {block} tags
Some examples:
WORKING (without nested variable inside "param")
{block name=CONTENT}
{assign "extra" value="test"}
DropDown: {include "dropdown.html" param="product_name" items=DS::PRODUCTS()}
{/block}
NOT WORKING #1 (with nested variable using `` )
{block name=CONTENT}
{assign "extra" value="test"}
DropDown: {include "dropdown.html" param="product_name_`$extra`" items=DS::PRODUCTS()}
{/block}
NOT WORKING #2 (with nested variable using {} )
{block name=CONTENT}
{assign "extra" value="test"}
DropDown: {include "dropdown.html" param="product_name_{$extra}" items=DS::PRODUCTS()}
{/block}
When I am using {include} without {block} all examples are ok
Question: is there any other method to allow nested variables or is it a known issue?
Thank you in advance
PingBack: http://stackoverflow.com/questions/30346782/smarty-template-3-1-error-variable-template-file-names-not-allow-within-block |
|
Back to top |
|
AnrDaemon Administrator
Joined: 03 Dec 2012 Posts: 1785
|
Posted: Fri May 22, 2015 10:12 pm Post subject: Re: Smarty Template 3.1 ERROR: variable template file names |
|
|
intuz wrote: | OOP template tag {block} |
What OOP has to do with it?
Quote: | Its working pretty good, but I also noticed when I use {block} - tags the {include file="[...]" variableX="[..]"} breaks when I use nested variables. |
You MUST NOT use it that way. Assembling inherited templates is a compile-time process. You are likely to run into a nasty case of information leak with such techniques.
If you feel the need for such techniques, this means that your design is flawed and needs to be redone from scratch. |
|
Back to top |
|
U.Tews Administrator
Joined: 22 Nov 2006 Posts: 5068 Location: Hamburg / Germany
|
Posted: Fri May 22, 2015 11:09 pm Post subject: |
|
|
It does look like that "dropdown.html" does include another subtemplate which has its name assembled by the param parameter, right?
Currently template inheritance is a compile time process. This does not work when you use variable subtemplates which could contain {block} tags.For this reason variable subtemplates are not allowed as default.
You can set $smarty->inheritance_merge_compiled_includes = false;
But you must carefully read the INHERITANCE_RELEASE_NOTES how to handle
subtemplates with {block} tags in this case. |
|
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
|