FormBuilder: Flat file name by variable

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
superstoffe
Forum Members
Forum Members
Posts: 50
Joined: Fri Jan 16, 2009 1:07 pm

FormBuilder: Flat file name by variable

Post 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 :)
superstoffe
Forum Members
Forum Members
Posts: 50
Joined: Fri Jan 16, 2009 1:07 pm

Re: FormBuilder: Flat file name by variable

Post 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 :)
superstoffe
Forum Members
Forum Members
Posts: 50
Joined: Fri Jan 16, 2009 1:07 pm

Re: FormBuilder: Flat file name by variable

Post 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?
superstoffe
Forum Members
Forum Members
Posts: 50
Joined: Fri Jan 16, 2009 1:07 pm

Re: FormBuilder: Flat file name by variable

Post by superstoffe »

I'm back to this issue. Anyone that could take second to help me out?
User avatar
sjg
Power Poster
Power Poster
Posts: 310
Joined: Thu Jan 27, 2005 5:11 pm
Location: Los Angeles, CA

Re: FormBuilder: Flat file name by variable

Post 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___
Many modules available from the http://dev.cmsmadesimple.org
The CMS Made Simple Developer Cookbook is now available from Packt Publishers!
Post Reply

Return to “Modules/Add-Ons”