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

Assign Vars by useing assign::function

 
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 -> Plugins
View previous topic :: View next topic  
Author Message
icepack
Smarty Rookie


Joined: 20 Jan 2004
Posts: 5
Location: Germany

PostPosted: Tue Jan 20, 2004 10:45 am    Post subject: Assign Vars by useing assign::function Reply with quote

Why does it not work? Crying or Very sad

// ----------------------
$smarty->assign("test1","value of test1");
// ----------------------

{assign var="test2" value="$test1 in document"}

Or is it a bug?
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Tue Jan 20, 2004 10:54 am    Post subject: Reply with quote

sorry, i forgot my magic glass today. it would be nice if you let us know:
what do you expect?
what do you get?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
icepack
Smarty Rookie


Joined: 20 Jan 2004
Posts: 5
Location: Germany

PostPosted: Tue Jan 20, 2004 12:26 pm    Post subject: Reply with quote

The problem is that smarty not replace the assigned vars by useing a function like {assign var="var1" value="value1"}.

index.php:
[php:1:673754922b]<?php

$smarty = new Smarty;
$smarty->assign('foo',array('value'=>'value of foo');
$smarty->display('document.tpl');

?>[/php:1:673754922b]

document.tpl:
Code:
<body>
{$foo.value}

{assign var="foo2" value="$foo.value in document.tpl"}
{$foo2}
</body>


Output:
Code:
<body>
value of foo

Array.value
</body>


do you understand my problem?
Back to top
View user's profile Send private message
messju
Administrator


Joined: 16 Apr 2003
Posts: 3336
Location: Oldenburg, Germany

PostPosted: Tue Jan 20, 2004 12:49 pm    Post subject: Reply with quote

http://smarty.php.net/manual/en/language.syntax.quotes.php
Back to top
View user's profile Send private message Send e-mail Visit poster's website
icepack
Smarty Rookie


Joined: 20 Jan 2004
Posts: 5
Location: Germany

PostPosted: Tue Jan 20, 2004 1:36 pm    Post subject: Reply with quote

Thank you, it works... Very Happy
Back to top
View user's profile Send private message
FredyC
Smarty n00b


Joined: 27 Jul 2005
Posts: 2
Location: Czech Republic

PostPosted: Wed Jul 27, 2005 7:33 pm    Post subject: Reply with quote

Hi, i have similar problem, but in this case it doesn't work.

{assign var=ClientFullName value=`$Client.ClientTitle $Client.ClientFirstName $Client.ClientLastName`}

...and a get error

"Fatal error: Smarty error: [in Sub_Fixed_Client_list.tpl line 24]: syntax error: invalid attribute name: '$Client.ClientFirstName' (Smarty_Compiler.class.php, line 1524)"

...when i try

{assign var=ClientFullName value="`$Client.ClientTitle $Client.ClientFirstName $Client.ClientLastName`"}

...and display content of var, i get

`Array.ClientTitle Array.ClientFirstName Array.ClientLastName`

So where is the catch ?
Back to top
View user's profile Send private message
boots
Administrator


Joined: 16 Apr 2003
Posts: 5611
Location: Toronto, Canada

PostPosted: Wed Jul 27, 2005 7:36 pm    Post subject: Reply with quote

backtick is not so magical. You use it around SINGLE variable references.

{assign var=ClientFullName value="`$Client.ClientTitle` `$Client.ClientFirstName` `$Client.ClientLastName`"}
Back to top
View user's profile Send private message
FredyC
Smarty n00b


Joined: 27 Jul 2005
Posts: 2
Location: Czech Republic

PostPosted: Thu Jul 28, 2005 8:40 am    Post subject: Reply with quote

Nice, thank you very much, it works.
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 -> Plugins 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