Export to CSV without using dialog

juanmarmol

New Member
Hello,

I tried using the export to CSV through a URL capability:

index.php?option=com_fabrik&view=list&listid=5&jp_jaz_productos_pedido___pedido=24&resetfilters=1&format=csv&download=0

Unfortunately, I've got the following message in the generated page:

{"total":"4","count":100,"file":"jp_jaz_productos_pedido-export.csv","limitStart":0,"limitLength":100}

Do you know what is going on?

Thanks in advance for all your help.

Regards,

Juan
 
What do you expect with download=0?
It's working fine without download param.

Edit: I just found that download=0 is in the WIKI.
I don't know why. It's working fine with download=1 or without download.
 
Last edited:
Hello,

Thanks for your prompt reply. Before posting I tested with download=1, and it didn't work. Now I tested it without the download parameter and I get exactly the same page:

{"total":"4","count":100,"file":"jp_jaz_productos_pedido-export.csv","limitStart":0,"limitLength":100}

As you mentioned,I only followed the instructions that I found at your wiki. The page does change the total number of rows that are withdrawn, but does't download any file.
 
I just tried this out (never used it before) and it seems to work fine for me. (Pretty cool).

The only way I get that Json response that you are getting is if &download=0. (I just changed that to &download=1 in the Wiki). And of course, if the user doesn't have the required access level for the listid that is given, then there is a 'You are not authorized...' message. So it all seems to work fine for me.

Re-check the URL after you try editing it. It will always revert back to the previous URL (or maybe you inadvertently selected the URL that your browser found in its history as you were trying to change the url - that happens to me all the time) - I bet you thought you changed something but you really didn't.

That said, someone should fix the code in the display() function in view.csv.php so that if $canDownload is false some kind of message is displayed rather than the Json string being echoed to the screen.

And I'm wondering... Why did you include that "&jp_jaz_productos_pedido___pedido=24" and "resetfilters=1' in the URL? You didn't follow the syntax example in the Wiki exactly. (But just for the heck of it, I even tried adding an irrelevant request parameter like that to the URL and it still worked!)

If you are trying to get only that element value in the csv export, the correct syntax is show in the Wiki as "&fields[tablename___elementname]=1&fields[tablename___elementname2]=1". So that would be &fields[jp_jaz_productos_pedido___pedido]=1 if you are trying to get the jp_jaz_productos_pedido___pedido element value only. And that would include the raw value also. You'd have to also add '&incraw=0' to remove the raw value. If you want to remove the filters you would add '&incfilters=0'. I tried all that and it works as expected too.
 
Last edited:
Hello Bauer,

Thank you very much for your reply. I modified the URL, I was wrongly calling it from /administrator/index.php instead of /index.php. Made that change and it worked.

The only thing is that it does not retrieve the parameters set at the list/publishing/CSV section. I had to remove manually the raw data using the incraw=0 and indicate each of the fields I wanted to be included in the file through the URL parameters as you mentioned earlier. The final URL is:

index.php?option=com_fabrik&view=list&listid=5&jp_jaz_productos_pedido___pedido=24&resetfilters=1&incraw=0&format=csv&download=1&fields[jp_jaz_productos_pedido___usuario]=1&fields[jp_jaz_productos_pedido___usuario]=1&fields[jp_jaz_productos_pedido___categoria]=1&fields[jp_jaz_productos_pedido___producto]=1&fields[jp_jaz_productos_pedido___cantidad]=1&fields[jp_jaz_productos_pedido___unidad_de_medida]=1&fields[jp_jaz_productos_pedido___estatus]=1

I Included "&jp_jaz_productos_pedido___pedido=24" and "resetfilters=1" in the URL because I want to generate a particular subset of the data contained in the jp_jaz_productos_pedido table, and it worked perfectly.

By the way, do you know how can I hide the "CSV" or "Group By" menus showed in the list view?

Thanks again for your help.
 
I'm wondering why you felt the need to use the URL method to begin with when the CSV Import/Export options are configurable for every Fabrik list (with further relevant settings, like adding additional or special filters, or specifying the included elements, available in the 'Fabrik List Options' tab in the Menu configuration). Though I'm glad I read your post because I wasn't aware that 'CSV download via URL' feature even exists - and I've been using Fabrik for 3 years. There's always a lot to learn, but I suppose that's my fault for not taking more time to read the Wiki.

The visibility of both the CSV and Group by options is determined by user access level.
In the admin backend parameters for the Fabrik List...
'CSV' options are under 'Publishing' (Click the CSV tab). You can just set your configuration there - and if you don't want the user to change any of it set the 'Front end' access to No. For 'Group By' look under 'Data' - 'Group by' tab. That is where you set the group by options - and which user access level can change (see) them.
 
Last edited:
Thank you very much Bauer, I removed the menus successfully with your instructions.

The problem is that I have a joined list, where I see all the invoices (one table) and all the products of each invoice (another table) in a single list (see attached image). If I export the CSV file directly from the menu, it includes only one row per invoice and all the products that belong to that invoice are smashed into a single row, without any way to distinguish between one product an another automatically.

After I reviewed the code that generates the CSV file, I concluded that If I changed the way the lists were treated could affect the performance of another module, so the easiest solution was adding a button at the end of each invoice in the join list. In that way the CSV file would include all the products of a particular invoice (pedido). Does that make any sense? Is there any other way of solving this more efficiently?
 

Attachments

  • invoice.jpg
    invoice.jpg
    129.8 KB · Views: 139
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top