Page 1 of 1

*SOLVED*Pass php variable to UDT

Posted: Wed Dec 30, 2009 2:11 pm
by Akonkagva
UDT PART: echo ' Hello ' . $params['name'] . '!';
TEMPLATE PART: {helloworld name='Bob'}
work's fine
But when I need to pass php variable like:
UDT PART: echo 'Hello ' . $params['name'] . '!';
TEMPLATE PART:
TEMPLATE PART: {helloworld name='$bob'}
It doesn't work as it should.
How to pass php varialbe to UDT ?

Thank you for your answers and Happy NEW YEAR !

Re: Pass php variable to UDT

Posted: Thu Dec 31, 2009 8:44 am
by fredp
Akonkagva wrote: ...
UDT PART: echo 'Hello ' . $params['name'] . '!';
TEMPLATE PART:
TEMPLATE PART: {helloworld name='$bob'}
It doesn't work as it should.
How to pass php varialbe to UDT ?

Thank you for your answers and Happy NEW YEAR !
Hi,

I think you might want to improve/refresh your PHP and Smarty knowledge a bit. ;) 

Remember that PHP handles single-quoted strings and double-quoted strings differently.  A review of the PHP docs might prove helpful in understanding the difference.  You might start here:
  http://www.php.net/manual/en/language.types.string.php

Similarly, a review of the Smarty docs may help you understand the differences between PHP variables and Smarty "template variables".  You might start with these pages:
  http://www.smarty.net/manual/en/language.variables.php
  http://www.smarty.net/manual/en/languag ... iables.php

Hope this helps,
Fred P.

Re: *SOLVED*Pass php variable to UDT

Posted: Tue Feb 16, 2010 10:48 am
by spngg
I'm also looking for a solution to this very problem, i've read the documentation in the links, but don't see a relation, does anyone have an example of how to pass in variables to a UDT?

thanks in advance