Reputation: 5023
I need to assign value for smarty var but it need to be mixed with some html or text like
{assign var="heading1" value='Hello $user <a href="#">logout</a>'}
HTML works but the $user
variable does not.
Upvotes: 1
Views: 5190
Reputation: 13557
In Smarty2 you would (for "complex variables" like $foo.bar.baz
) write something like
{assign var="heading1" value="Hello `$user` <a href='#'>logout</a>"}
in Smarty3 you could do
{$heading1 = "Hello {$user} <a href='#'>logout</a>"}
If you want that variable to be escaped (and yes, you want that), you could use a {capture}:
{capture assign="heading1"}Hello {$user|escape} <a href='#'>logout</a>{/capture}
In Smarty3 you could do
{$heading1 = "Hello {$user|escape} <a href='#'>logout</a>"}
Upvotes: 3
Reputation: 15379
In order to embed your PHP variable, you must use double quotes in smarty
.
For instance:
{assign var="heading1" value="Hello $user <a href='#'>logout</a>"}
should concatenate $user for you.
Upvotes: 2