|
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 |
Christian Smarty n00b
Joined: 19 Jun 2003 Posts: 4 Location: Hessen, Deutschland
|
Posted: Sun Jun 22, 2003 1:58 pm Post subject: {$variables} problems |
|
|
Hello. I want to include a variable of my php scripts into my templates with {$var1} but at runtim $var1 is NULL. (I checked this with {php}var_dump($var1);{/php})
<?php
include("Smarty.class.php");
$smarty = new Smarty;
$var1="Hallo Welt";
$smarty->display("test.tpl");
?>
Does anybody has any ideas? |
|
Back to top |
|
SiliconError Smarty n00b
Joined: 21 Jun 2003 Posts: 4
|
Posted: Sun Jun 22, 2003 2:23 pm Post subject: |
|
|
Did you forget to assign?
[php:1:40f490cfce]<?php
include("Smarty.class.php");
$smarty = new Smarty;
$var1="Hallo Welt";
$smarty->assign("var1", $var1);
$smarty->display("test.tpl");
?>[/php:1:40f490cfce] |
|
Back to top |
|
Christian Smarty n00b
Joined: 19 Jun 2003 Posts: 4 Location: Hessen, Deutschland
|
Posted: Sun Jun 22, 2003 6:03 pm Post subject: |
|
|
SiliconError wrote: | Did you forget to assign?
[php:1:9906da111d]<?php
include("Smarty.class.php");
$smarty = new Smarty;
$var1="Hallo Welt";
$smarty->assign("var1", $var1);
$smarty->display("test.tpl");
?>[/php:1:9906da111d] |
ah. Thanks!
I didnīt know that smarty requires such a thing.
but then I try to access it via PHP embedd in Smarty it failes
Code: | {php}
var_dump($var1);
{/php} |
|
|
Back to top |
|
haste Smarty Rookie
Joined: 07 Jun 2003 Posts: 17
|
Posted: Sun Jun 22, 2003 7:37 pm Post subject: |
|
|
Christian wrote: | SiliconError wrote: | Did you forget to assign?
[php:1:e57df5582d]<?php
include("Smarty.class.php");
$smarty = new Smarty;
$var1="Hallo Welt";
$smarty->assign("var1", $var1);
$smarty->display("test.tpl");
?>[/php:1:e57df5582d] |
ah. Thanks!
I didnīt know that smarty requires such a thing.
but then I try to access it via PHP embedd in Smarty it failes
Code: | {php}
var_dump($var1);
{/php} |
|
No no. You want this in your .php file:
[php:1:e57df5582d]<?php
include("Smarty.class.php");
$smarty = new Smarty;
$var1="Hallo Welt";
$smarty->assign("var1", $var1);
$smarty->display("test.tpl");
?>[/php:1:e57df5582d]
And this in your .tpl file:
[php:1:e57df5582d]
The variable is: {$var}
[/php:1:e57df5582d] |
|
Back to top |
|
Christian Smarty n00b
Joined: 19 Jun 2003 Posts: 4 Location: Hessen, Deutschland
|
Posted: Sun Jun 22, 2003 7:44 pm Post subject: |
|
|
haste wrote: | Christian wrote: | SiliconError wrote: | Did you forget to assign?
[php:1:9965a04bdb]<?php
include("Smarty.class.php");
$smarty = new Smarty;
$var1="Hallo Welt";
$smarty->assign("var1", $var1);
$smarty->display("test.tpl");
?>[/php:1:9965a04bdb] |
ah. Thanks!
I didnīt know that smarty requires such a thing.
but then I try to access it via PHP embedd in Smarty it failes
Code: | {php}
var_dump($var1);
{/php} |
|
No no. You want this in your .php file:
[php:1:9965a04bdb]<?php
include("Smarty.class.php");
$smarty = new Smarty;
$var1="Hallo Welt";
$smarty->assign("var1", $var1);
$smarty->display("test.tpl");
?>[/php:1:9965a04bdb]
And this in your .tpl file:
[php:1:9965a04bdb]
The variable is: {$var}
[/php:1:9965a04bdb] |
I need the variable also in {php}{/php}-Blocks. How to do so? |
|
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
|