Re: [SMARTY] passing variables
| From: | Monte Ohrt | Date: | Wed, 10 Jul 2002 15:13:29 +0000 |
| Subject: | Re: [SMARTY] passing variables | ||
| References: | 1 | Groups: | php.smarty.general |
| Request: | Send a blank email to php-smarty-general+get-5246@lists.php.net to get a copy of this message | ||
You cannot nest template tags.
{include file="$filename.tpl"}
Henno Täht wrote:
Hi,
I love smarty but sometimes it's confusing. I want to include a file which
name is obtained from the url:
template.tpl
------------
{php}
if ($_GET[filename]){
$this->assign('filename', $_GET[filename]); # filename=myfile.txt
}
{/php}
{if $filename == "myfile.txt"}
Including $filename
{include file="{$filename}.tpl"}
{/if}
This gives me the following on the screen:
Including myfile.txt
Warning: Smarty error: unable to read template resource: ".tpl" in /var/www/smarty/Smarty.class.php on line 546
..But it works, if I include template.tpl itself from anothertemplate.tpl like this:
anothertemplate.tpl
-------------------
{php}
$this->assign('filename', 'myfile');
{/php}
{include file="template.tpl" filename="{$filename}"}
Is there any trick to avoid using a wrapper template or am I just missing
something here?
TIA,
Henno
--
Monte Ohrt <monte@ispi.net>
Director of Technology, ispi Inc.