Skip to content

Instantly share code, notes, and snippets.

@timodwhit
Last active August 29, 2015 14:20
Show Gist options
  • Save timodwhit/b8aab8f5455b3a522ff1 to your computer and use it in GitHub Desktop.
Save timodwhit/b8aab8f5455b3a522ff1 to your computer and use it in GitHub Desktop.
Get a list of views of a certain type
// Return an array of Data Export Views for a select list.
$vde_views = array();
// It is true, there is no better way to parse the views.
$views = views_get_enabled_views();
// Loop through each enabled views.
foreach ($views as $view) {
$id = $view->name;
$human_name = $view->human_name;
// Now loop through each display of each view.
foreach ($view->display as $display) {
// Only add it to the list if it is a views_data_export view.
if ($display->display_plugin == 'views_data_export') {
$friendly = $human_name . ': ' . $display->display_title;
$vde_views[$id . '--' . $display->id] = $friendly;
}
}
}
return $vde_views;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment