passing variables
| From: | Henno Täht | Date: | Wed, 10 Jul 2002 15:09:19 +0000 |
| Subject: | passing variables | ||
| Groups: | php.smarty.general | ||
| Request: | Send a blank email to php-smarty-general+get-5244@lists.php.net to get a copy of this message | ||
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