Do you have some feature in mind that you'd love to see in Couch? Let us know.
5 posts Page 1 of 1

My client requested a new feature to export some information to CSV.

I'm using DataBound Forms to get some data and he would like to download and import into other software.

Yeah, this would be a cool feature! Export to / import from CSV would be very useful not only for couch cart solutions but for simple websites also, since the databound forms give us the opportunity to collect informations from users/visitors.
I could be wrong, but I think Couch may already be able to do this. See, Couch is already able to return different types of files - not just PHP...

If you have a look at the RSS Tutorial in the documentation, it shows you how to use Couch to produce RSS feeds - which are basically just XML files. The RSS Tutorial is here:

Now, if you pay close attention to the tutorial, you'll see that the main 'trick' there is to use the content_type tag, to make sure that the browser will know, that it's downloading an RSS feed, and not a normal web page.

In your case, you'd use the tag to let the browser know, that it's downloading a CSV file, like this:

Code: Select all
<cms:content_type 'text/csv' />

And how about creating the CSV file itself? A CSV file is just a list of "comma-separated values". This means, that the CSV file usually contains a list of records (each record is in a line by itself, separated by a line break from the other records), and inside each line, each record field/column is separated from the others by a comma. You can find out more about the (very simple) CSV format, here:

You can produce such a list using the normal pages/folders/etc. tags:

<?php require_once('couch/cms.php'); ?>
<cms:content_type 'text/csv' />
<cms:pages masterpage='cars.php'>
<cms:show k_page_title />,<cms:show car_manufacturer />,<cms:show car_year />

<?php COUCH::invoke(); ?>

In theory, that would produce a CSV listing all the cars' models (title), manufacturers and years.

Of course, I'm just blabbering on without having actually tried it, so YMMV - but, at least in theory, it should work! :)

I hope this helps!
luxlogica I tested and it worked! Congratulations it is a excellent solution.

Thanks for sharing.
@luxlogica Thank you for sharing with us this tip!

@RafaelNC Good to know that this solution is a functional one!

I intended to give it a try also, but currently I struggle with CSV import. As Couch doesn't offer an option for importing from CSV, I have created a separate table in which I'm importing my data, and also managed to display all imported data in a couch driven template via PHP, the main issue remaining is to filter the imported data to display only data related to the logged in member.
Does anyone have any idea if this is doable or not, and if it can be accomplished, how it's possible?
5 posts Page 1 of 1

Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest
(based on users active over the past 5 minutes)

Users browsing this forum: No registered users and 1 guest