Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
The Views advanced help has a small section on Bulk Exports but it's difficult to find (help/views/api-default-views) and not a start-to-finish tutorial. My next comment will contain a more newbie-friendly tutorial. Please suggest edits.
Comment | File | Size | Author |
---|---|---|---|
#8 | example-bulk-export.txt | 3.05 KB | kbk |
#8 | views.help_.bulk-export.patch | 335 bytes | kbk |
#6 | example-bulk-export.txt | 3.13 KB | kbk |
Comments
Comment #1
kbk CreditAttribution: kbk commentedThis "how to" focuses on the bulk export and version control functionality of the Views module. The following steps document how to export multiple views at once and create a module from the exported code that will allow you to revert any subsequent changes to your views.
Assumptions:
- You know how to install and enable a module
- You have views you want to bulk export; we'll call them myView1 and myView2
Modules
- Views (specifically 6.x-2.x)
1) Install Views 2 and enable (/admin/build/modules) the following modules: Views, Views exporter, Views UI
2) Navigate to the Views Administration page (admin/build/views)
- You should have "Edit | Export | Clone | Delete" options next to myView1 and myView2. Once we're done, "Delete" will become "Revert"!
3) Navigate to the Bulk Export page to export myView1 and myView2. Click Tools > Bulk Export or browse to admin/build/views/tools/export.
4) Export myView1 and myView2
- Check the boxes to the left of myView1 and myView2
- Choose a module name: my_views
- Click Export
5) Create a module from the exports
$ cd sites/all/modules
$ sudo mkdir my_views
$ cd my_views
- Create the following files, paste in the appropriate code, and place them into the my_views directory:
my_views.info
my_views.module (add a <?php tag at the beginning of this file!)
my_views.views_default.inc (add a <?php tag at the beginning of this file!)
6) Clear the cache (just to be safe!)
- Navigate to admin/settings/performance > Clear cached data
6) Enable the my_views module (admin/build/modules)
- the module name should be "my_views Export Module"
7) Navigate to the Views Admin page (admin/build/views) Verify that you now have version control abilities for myView1 and myView2.
- The right of these should now read "Edit | Export | Clone | Revert"
Comment #2
dawehnerThat's a good tutorial!
What about making it as a patch for the advanced help? I guess it's much easier to find it directly in the module.
Comment #3
jdvc CreditAttribution: jdvc commentedWow, that just saved me so much time. Thanks a lot!
Comment #4
kbk CreditAttribution: kbk commented@dereine, I can put a patch together. I'm assuming I should mimic the examples already in advanced help (i.e., help/views/example-users-by-role)?
Comment #5
dawehnerSure it makes sense to look at existing examples.
If you need help with creating a patch i can help you on irc.
Comment #6
kbk CreditAttribution: kbk commentedOK, see the attached patch. Not really sure if anything else needs to happen to make this a proper patch. Just change .txt to .html and it should fit in well with the other files in views/help.
Comment #7
dawehnerIsn't a .ini entry required, too? I'm not sure here.
Comment #8
kbk CreditAttribution: kbk commentedI'm pretty sure you're correct dereine. See attached.
Notes:
example-bulk-export.txt > change file extension to html
views.help_.bulk-export.patch > patch for views.help.ini
Comment #9
kbk CreditAttribution: kbk commentedComment #10
esmerel CreditAttribution: esmerel commentedCommitted to 6.x-3.x