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:
http://www.couchcms.com/docs/concepts/rss-feeds.htmlNow, 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:
http://en.wikipedia.org/wiki/Comma-separated_valuesYou 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 />
</cms:pages>
<?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!