Skip to content

Instantly share code, notes, and snippets.

@damiankloip
Created July 17, 2012 16:43
Show Gist options
  • Save damiankloip/3130514 to your computer and use it in GitHub Desktop.
Save damiankloip/3130514 to your computer and use it in GitHub Desktop.
class views_handler_filter_entity_type extends views_handler_filter_in_operator {
function get_value_options() {
if (!isset($this->value_options)) {
$table_data = views_fetch_data($this->view->base_table);
$this->entity_type = $table_data['table']['entity type'];
$info = entity_get_info($this->entity_type);
$types = $info['bundles'];
$this->value_title = t('@entity types', array('@entity' => $info['label']));
$options = array();
foreach ($types as $type => $info) {
$options[$type] = t($info['label']);
}
asort($options);
$this->value_options = $options;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment