Page 1 of 1

Assign a variable

Posted: Thu Dec 03, 2015 7:05 pm
by Barrowboy
Hi
Need some help with assigning one variable to another.

{assign var=AnyVariable value= Withmind}
{assign var=$AnyVariable value= $Withmind}

This is what I've tried but both fail.
Also tried $1 = $2

Can someone give me a working formula to transfer one variable to another. Does smarty come in somewhere.

Would like to put the code into UDT if poss.

A bit thick on this subject.

Thanks

Re: Assign a variable

Posted: Thu Dec 03, 2015 7:15 pm
by Rolf
Don't forget the scope parameter, examples: http://www.cmscanbesimple.org/blog/smar ... e-examples

Re: Assign a variable

Posted: Fri Dec 04, 2015 10:36 am
by velden

Code: Select all

{assign var=AnyVariable value= Withmind}
{assign var=$AnyVariable value= $Withmind}

try:
{assign var=AnyVariable value=$Withmind}
or short:
{$AnyVariable=$Withmind}

Re: Assign a variable

Posted: Sat Dec 05, 2015 8:50 am
by Barrowboy
Hi
Thanks for your suggestions but still unable to get it working.

{assign var=AnyVariable value=$Withmind}
or short:
{$AnyVariable=$Withmind}

Trying your suggestions,
the var shows error T_Var and the other one errors with Evali.

Below is what I have tried and does not error but the result not correct.

$smarty->assign('temp' , $temp1);

I am trying just to copy one var to the other and this within a UDT and then just call the UDT in template.

No luck, it seems an easy thing to try but the formula is not correct.

Any further help would be appreciated.

Re: Assign a variable

Posted: Thu Dec 24, 2015 11:17 pm
by Jeff
You probably should post your whole template.

What is the UDT for? to do the assignment or something else?