Every default view should be a different file (and should be in a subfolder)

proposed new file structure:
- enabled_modules.info
- enabled_modules.module
- enabled_modules.install
-- views
--- views/exports
--- views/exports/enabled_modules.inc
--- views/exports/enabled_modules_admin.inc

Comments

pasqualle’s picture

required code:

/**
 * Implements hook_views_api().
 */
function enabled_modules_views_api() {
  return array(
    'api' => 3,
    'path' => drupal_get_path('module', 'enabled_modules') . '/views',
  );
}

/**
 * Implements hook_views_default_views().
 */
function  enabled_modules_views_default_views() {
  $module = 'enabled_modules';
  $views = array();
  $path = drupal_get_path('module', $module) . '/views/exports';
  $files = drupal_system_listing('/.inc$/', $path, 'name', 0);
  foreach ($files as $file) {
    include_once DRUPAL_ROOT . '/' . $file->uri;
    if (isset($view->name)) {
      $views[$view->name] = $view;
    }
  }

  return $views;
}

pasqualle’s picture

the export files should just contain the export generated by the views module (plus <?php on the first line)

juliangb’s picture

Is this a standard? I haven't seen this set up in other modules.

pasqualle’s picture

It is not, yet. It is much easier to work with views exports if you do not have all the views in one big file.
The code to find the views export files, is not mine, I've found it on the internet. So I am not the only one separating the exports into different files.

pasqualle’s picture

juliangb’s picture

Status: Active » Postponed

Waiting on whether it becomes a standard.

juliangb’s picture

Issue summary: View changes

missing file extension