« Bulk Modify Access Permissions of Views in Drupal | Main | How to redirect user upon first login in Drupal »
November 17, 2010
Advanced help patch for Views
This "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 have views you want to bulk export; we'll call them myView1 and myView2
- You know how to install and enable a module
Modules
- Views (specifically 6.x-2.x)
Modules you will need
Install Views 2 and enable the following modules: Views, Views exporter, Views UI
Evaluate the Current State of Things
Navigate to the Views Administration page. You should have Edit | Export | Clone | Delete options next to myView1 and myView2. Once we're done, "Delete" will become "Revert"!
Bulk Export Your Views
- Click Tools > Bulk Export to navigate to the Bulk Export page to export myView1 and myView2.
- Check the boxes to the left of myView1 and myView2
- Choose a module name: my_views
- Click Export
Create a Module from the Exported Views
The results of the export should now be in front of you. Specifically, the results page should be composed of three code-containing regions. This code and the following steps are all you need to create a module that will allow you to revert your views to the state they were in when you exported them.
- Create a directory called my_views within your sites/all/modules directory.
- 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!)
Clear the cache
Just to be safe. Navigate to the Performance Administration page and Clear cached data.
Enable the Module Containing Exported Views
Navigate to the Modules Administration page and enable my_views Export Module. Save.
Verify Presence of Reversion Option for Exported Views
Navigate to the Views Administration page. The right of myView1 and myView2 should now read Edit | Export | Clone | Revert. Congratulations, you now have version control in place for your exported views!
Posted by kkwaiser at November 17, 2010 09:19 AM