Smarty Forum Index Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon.

{$variables} problems

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General
View previous topic :: View next topic  
Author Message
Christian
Smarty n00b


Joined: 19 Jun 2003
Posts: 4
Location: Hessen, Deutschland

PostPosted: Sun Jun 22, 2003 1:58 pm    Post subject: {$variables} problems Reply with quote

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
View user's profile Send private message
SiliconError
Smarty n00b


Joined: 21 Jun 2003
Posts: 4

PostPosted: Sun Jun 22, 2003 2:23 pm    Post subject: Reply with quote

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
View user's profile Send private message
Christian
Smarty n00b


Joined: 19 Jun 2003
Posts: 4
Location: Hessen, Deutschland

PostPosted: Sun Jun 22, 2003 6:03 pm    Post subject: Reply with quote

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
View user's profile Send private message
haste
Smarty Rookie


Joined: 07 Jun 2003
Posts: 17

PostPosted: Sun Jun 22, 2003 7:37 pm    Post subject: Reply with quote

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
View user's profile Send private message
Christian
Smarty n00b


Joined: 19 Jun 2003
Posts: 4
Location: Hessen, Deutschland

PostPosted: Sun Jun 22, 2003 7:44 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    Smarty Forum Index -> General All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP