« 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.

- You have views you want to bulk export; we'll call them myView1 and myView2
- You know how to install and enable a module

- Views (specifically 6.x-2.x)

  1. Modules you will need

    Install Views 2 and enable the following modules: Views, Views exporter, Views UI

  2. 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"!

  3. Bulk Export Your Views

    1. Click Tools > Bulk Export to navigate to the Bulk Export page to export myView1 and myView2.
    2. Check the boxes to the left of myView1 and myView2
    3. Choose a module name: my_views
    4. Click Export
  4. 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.

    1. Create a directory called my_views within your sites/all/modules directory.
    2. 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!)
  5. Clear the cache

    Just to be safe. Navigate to the Performance Administration page and Clear cached data.

  6. Enable the Module Containing Exported Views

    Navigate to the Modules Administration page and enable my_views Export Module. Save.

  7. 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


Login to leave a comment. Create a new account.