Hi,
Can this be done by smarty?
User add lines to ListIt's text area:
Green
Yellow
Black
Can these lines convert to variables?
What if there are character at end of the line:
Green;
Yellow;
Black;
-R
[Solved]One text field to multiple smarty variables
[Solved]One text field to multiple smarty variables
Last edited by Recon on Wed Jan 01, 2014 5:52 am, edited 1 time in total.
Re: One text field to multiple smarty variables
Why not to an array?
Use a one line text box and enter: Green,Yellow,Black
Then you can:
It should work (didn't test it). For syntax specifics search the Smarty site.
Use a one line text box and enter: Green,Yellow,Black
Then you can:
Code: Select all
{assign var=mySmartyArray value=","|explode:$string_with_commas}
{$mySmartyArray[0]}{*Green*}
{$mySmartyArray[1]}{*Yellow*}
{$mySmartyArray[2]}{*Black*}
"There are 10 types of people in this world, those who understand binary... and those who don't."
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
* by the way: English is NOT my native language (sorry for any mistakes...).
Code of Condut | CMSMS Docs | Help Support CMSMS
My developer Page on the Forge
GeekMoot 2015 in Ghent, Belgium: I was there!
GeekMoot 2016 in Leicester, UK: I was there!
DevMoot 2023 in Cynwyd, Wales: I was there!
Re: One text field to multiple smarty variables
Maybe I would then explode using the line feed character in stead of comma (IF possible using explode inside smarty).
Note that you might want to trim spaces from the variables after that as 'users' don't consider invisible characters but your code probably does.
Note that you might want to trim spaces from the variables after that as 'users' don't consider invisible characters but your code probably does.
Re: One text field to multiple smarty variables
This works and just what I needed. Thank You!Jo Morg wrote:Why not to an array?
Use a one line text box and enter: Green,Yellow,Black
Then you can:It should work (didn't test it). For syntax specifics search the Smarty site.Code: Select all
{assign var=mySmartyArray value=","|explode:$string_with_commas} {$mySmartyArray[0]}{*Green*} {$mySmartyArray[1]}{*Yellow*} {$mySmartyArray[2]}{*Black*}