Adding a CSV Export button to Drupal 6 Views displays

Dev

Adding a CSV Export button to Drupal 6 Views displays

Views is something that a lot of Drupal developers (myself included) likely could not do without. It provides a great way for us to display, sort, filter, and manage data and content for a huge variety of uses. One such use is exporting this collection of data as a CSV file. We can make this incredibly convenient using only one other module aside from Views – the Views Bonus Pack.

What We Want

  • A collection of data created using the Views module
  • A button to easily export the data to a CSV file

What We Need

What We Do

For the first step, we need to know what content we are going to pull into a CSV file. We can either build a view from scratch or use a current view. The CSV export functionality can be added to a view that has already been created.

Once the view is built, we need to add a new Feed display. Select Feed from the display dropdown and click Add Display. From here, we have the option to customize a few things, including the display fields. This is useful in case we want the CSV file to store different fields than we see in our normal View display.

The next step is to actually change the display style to CSV. The style should default to RSS Feed under Basic Settings, so we just need to click there to change it. Clicking on the gear on the right side of the Style field gives us access to change the style settings, including the separator character, whitespace trimming, and even parent sorting.

The final step to add our CSV button to the View is to fill out the Feed Settings. Here we need to set Path and Attach To. For instance, if we are outputting a View of student names, we could set the path to students.csv – be sure to add the .csv extension so that the path outputs it as a CSV file or you may receive a 404 error! The Attach To field determines which Views displays will include the CSV button. Select all the displays on which you’d like to include the button, click save, and we are finished!

There should now be a nice, orange box button below those displays, and you may change this to your liking with CSS.

More About the Author

Justin Lemmon

Analytics Consultant
Adding a CSV Export button to Drupal 6 Views displays Views is something that a lot of Drupal developers (myself included) likely could not do without. It provides a great way for us to ...
Creating a custom form page in Drupal 6 with a module Webforms are great when you want to make a quick and useful form in Drupal. However, sometimes we may want a little more control over ...

See more from this author →

Subscribe to our newsletter

  • I understand that InterWorks will use the data provided for the purpose of communication and the administration my request. InterWorks will never disclose or sell any personal data except where required to do so by law. Finally, I understand that future communications related topics and events may be sent from InterWorks, but I can opt-out at any time.
  • This field is for validation purposes and should be left unchanged.

InterWorks uses cookies to allow us to better understand how the site is used. By continuing to use this site, you consent to this policy. Review Policy OK

×

Interworks GmbH
Ratinger Straße 9
40213 Düsseldorf
Germany
Geschäftsführer: Mel Stephenson

Kontaktaufnahme: markus@interworks.eu
Telefon: +49 (0)211 5408 5301

Amtsgericht Düsseldorf HRB 79752
UstldNr: DE 313 353 072