Page 1 of 1

FormBuilder: Flat file name by variable

Posted: Mon Oct 05, 2009 12:00 pm
by superstoffe
Ok, I got this order system running, where you fill in a form, attach files etc. To that I've chosen to write all the orders to a flat file to keep some kind of a log.

Now though, we are trying to implement this fb system with our business system (importing csv/txt files). I'm however have trouble giving the files a variable name (i.e. based on date, id or whatever). In a perfect world you should have been able to just put {$orderid}.txt as the "Destination file" name. But now you can't.

So... is there any way to get around that? Prefarably with the Flat-file option.

- Save Flat-file as to 123456.txt for example {$orderid}.txt
- Or something similar..

How do the system store and fetch the filename information? Maybe I can sort it out manually in a simple.. even though Im limited in server sided coding skills :)

Re: FormBuilder: Flat file name by variable

Posted: Tue Oct 06, 2009 1:45 pm
by superstoffe
Anyone?

Ah well, I tried hardcode mod it in DispositionFile.class.php .. but since Im a terrible PHP coder I cant quite get it to work. Or am I just messing with the wrong variables?

(at around line 70):

Code: Select all

$filespec = $this->GetOption('fileroot',$options['uploads_root']).'/'.
preg_replace("/[^\w\d\.]|\.\./", "_", $this->GetOption('filespec','form_submissions.txt'));
to something like this:

Code: Select all

$db = &$mod->dbHandle;
$seq = $db->GenID(cms_db_prefix(). 'module_fb_uniquefield_seq');
$filespec = $this->GetOption('fileroot',$options['uploads_root']).'/'.
preg_replace($this->GetOption('filespec',$seq));
or even..

Code: Select all

$db = &$mod->dbHandle;
$seq = $db->GenID(cms_db_prefix(). 'module_fb_uniquefield_seq');
$filespec = $seq;
Am I on the right path here? Please help me :)

Re: FormBuilder: Flat file name by variable

Posted: Mon Oct 12, 2009 5:50 am
by superstoffe
I wish I could have replied that I solved this.. but I haven't..

No one have a slightest idea how to best get this to work?

Re: FormBuilder: Flat file name by variable

Posted: Thu Nov 26, 2009 9:08 am
by superstoffe
I'm back to this issue. Anyone that could take second to help me out?

Re: FormBuilder: Flat file name by variable

Posted: Tue Dec 01, 2009 11:47 pm
by sjg
If you want to use Smarty variables in the filespec, you could try doing something like:

Code: Select all


$filespec = $this->GetOption('fileroot',$options['uploads_root']).'/'.
      preg_replace("/[^\w\d\.]|\.\./", "_", $this->GetOption('filespec','form_submissions.txt'));

$filespec= $mod->ProcessTemplateFromData( $filespec);


Good luck,
___Samuel___