Created
June 11, 2010 11:46
-
-
Save jpstacey/434393 to your computer and use it in GitHub Desktop.
Clean Drupal hook_views_Default_views
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Implementation of hook_views_default_views | |
*/ | |
function example_views_default_views() { | |
return example_default_views_from_files(); | |
} | |
/** | |
* Helper function for default views - get from files in a subdirectory | |
*/ | |
function example_default_views_from_files($module = 'example', $subdir = 'views') { | |
$files = file_scan_directory(drupal_get_path('module', $module). "/$subdir", '.view'); | |
foreach ($files as $absolute => $file) { | |
require $absolute; | |
if (isset($view)) { | |
$views[$file->name] = $view; | |
} | |
if ($views[$file->name]->name != $file->name) { | |
drupal_set_message(t('The view @n has inconsistent naming and might not be overrideable in the views UI', | |
array('@n' => $file->name)), 'warning'); | |
} | |
} | |
return $views; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment