Page 1 of 1

Formbuilder flat file problem

Posted: Tue Apr 03, 2012 6:29 pm
by Nettie
I have a form where you can select an item via a checkbox and type in a textfield how many of that item you wish to order.

My problem is a bit difficult to explain and I simpy can't wrap my head around it.

I need to write the result to a flat text file. But insteadt of having the file look like this:

Item name
Amount 3

I need to duplicate the result so it ends up like this

Item name
Item name
Item name

If of course the amount is 1 it shouldnt duplicate at all.

My fields looks like this:

Code: Select all

<Item name:>{$TAB}{$TAB}{if $itemname != "" && $itemname != "[mangler]" }{$itemname}{/if}
{if $amount != "" && $amount!= "[mangler]" }{$amount}{/if}
Any help is highly appreciated :)

Re: Formbuilder flat file problem

Posted: Tue Apr 03, 2012 8:21 pm
by mcDavid
I think you will have to make a user defined tag for that. Something like this:

Code: Select all

$i=0;
while ($i < params['amount'])
{
  echo $params['name'];
  $i++;
}
and then call it with {item name=$itemname amount=$amount}

Smarty 3 will have native support for while-loops so you might be able to do this with only smarty if you can wait for Smarty 3 to appear in CMS MS (maybe in CMS 1.11)

Re: Formbuilder flat file problem

Posted: Tue Apr 03, 2012 9:39 pm
by calguy1000
Uhm... see the 'repeat' command in the tags menu?

Re: Formbuilder flat file problem

Posted: Tue Apr 03, 2012 10:13 pm
by Nettie
Calguy1000 I saw that one but it doesnt help. If the customer types 10 it has to repeat 10 times etc.

And btw ty for all the good work you have done with cmsms :)

Re: Formbuilder flat file problem

Posted: Tue Apr 03, 2012 10:28 pm
by mcDavid
calguy1000 wrote:Uhm... see the 'repeat' command in the tags menu?
Ah. Good one, seems to do exactly that!