There was a request last year in Features issue queue by kenorb for exporting Views into separate files.

#747028: Views export into separate files

The response from yhahn was that such functionality should first happen in CTools/Views. I looked for a ticket in the in the CTools and Views queues but could not find one. Has this been discussed previously? Could this be done with patches to the Bulk Export module?

Comments

merlinofchaos’s picture

I have thought about it but I have not yet moved forward on it, nor am have I quite decided the best way to actually do it. Bulk exporting a lot of different files is a little tricker; you need to move past cut & paste and actually produce files, at that point.

joelstein’s picture

Here's what we do:

/**
 * Implements hook_views_default_views().
 */
function mymodule_views_default_views() {
  $files = file_scan_directory(drupal_get_path('module', 'mymodule'). '/views/views', '/inc$/');
  foreach ($files as $filename => $file) {
    require $filename;
    $views[$file->name] = $view;
  }
  return $views;
}

/**
 * Implements hook_views_default_views_alter().
 */
function mymodule_views_default_views_alter(&$views) {
  $files = file_scan_directory(drupal_get_path('module', 'mymodule'). '/views/altered', '/inc$/');
  foreach ($files as $filename => $file) {
    if (isset($views[$file->name])) {
      require $filename;
      $views[$file->name] = $view;
    }
  }
}

Works pretty well. Then, we just drop all of our views into mymodule/views/views and name them the name of the view. When we want to export altered views provided by other modules, we put them in mymodule/views/altered.

stevector’s picture

Thanks joelstein. Do you have an automated way of getting those exported Views into mymodule/views/views the way Features or Bulk Export can?

joelstein’s picture

Well, as long as the file exists in the mymodule/views/views folder, Views will find it.

pasqualle’s picture

Version: 7.x-1.0-alpha4 » 7.x-1.x-dev
Component: Exportables » Bulk Exporter
stevector’s picture

I'm working on this functionality for Features module in a sandbox: http://drupal.org/sandbox/stevector/1392162

japerry’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

Drupal 7 is no longer supported, closing.

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.