View previous topic :: View next topic |
Author |
Message |
icepack Smarty Rookie
Joined: 20 Jan 2004 Posts: 5 Location: Germany
|
Posted: Tue Jan 20, 2004 10:45 am Post subject: Assign Vars by useing assign::function |
|
|
Why does it not work?
// ----------------------
$smarty->assign("test1","value of test1");
// ----------------------
{assign var="test2" value="$test1 in document"}
Or is it a bug? |
|
Back to top |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
Posted: Tue Jan 20, 2004 10:54 am Post subject: |
|
|
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 |
|
icepack Smarty Rookie
Joined: 20 Jan 2004 Posts: 5 Location: Germany
|
Posted: Tue Jan 20, 2004 12:26 pm Post subject: |
|
|
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 |
|
messju Administrator
Joined: 16 Apr 2003 Posts: 3336 Location: Oldenburg, Germany
|
|
Back to top |
|
icepack Smarty Rookie
Joined: 20 Jan 2004 Posts: 5 Location: Germany
|
Posted: Tue Jan 20, 2004 1:36 pm Post subject: |
|
|
Thank you, it works... |
|
Back to top |
|
FredyC Smarty n00b
Joined: 27 Jul 2005 Posts: 2 Location: Czech Republic
|
Posted: Wed Jul 27, 2005 7:33 pm Post subject: |
|
|
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 |
|
boots Administrator
Joined: 16 Apr 2003 Posts: 5611 Location: Toronto, Canada
|
Posted: Wed Jul 27, 2005 7:36 pm Post subject: |
|
|
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 |
|
FredyC Smarty n00b
Joined: 27 Jul 2005 Posts: 2 Location: Czech Republic
|
Posted: Thu Jul 28, 2005 8:40 am Post subject: |
|
|
Nice, thank you very much, it works. |
|
Back to top |
|
|