Karem
Karem

Reputation: 18123

Smarty template add to a variable error

Im trying to

    {$mouseOver = "test"}
    {$mouseOver .= " continue"}

Like i can do this in simple php:

$test = "Hello";
$test .= " continue";

echo $test; // will output: Hello continue

In Smarty PHP template. How can i do it right?

Upvotes: 0

Views: 89

Answers (2)

No Results Found
No Results Found

Reputation: 102874

v2p is on the right track, but specifically you would do it like this:

{assign var="varname" value="Hello"}
{assign var="varname" value="{$varname} World"}

{$varname}

This would print "Hello World", and $varname would continue to hold that value until further modified.

Upvotes: 1

Uladzimir Pasvistselik
Uladzimir Pasvistselik

Reputation: 3921

Try {assign var='name' value='some value'}

See http://www.smarty.net/docsv2/en/language.custom.functions.tpl#language.function.assign


What about string concatenation, use cat modifier

See http://www.smarty.net/docsv2/en/language.modifier.cat

Upvotes: 0

Related Questions