Views Filter Plugin: Wrapping Taxonomy tid

Events happening in the community are now at Drupal community events on www.drupal.org.
Grayside's picture

I am trying to dive into Views Plugin writing, and I suspect I've hit the deep end. Not sure where to post this, so I wandered in here.

I'm working on a module I've been calling OG Vocabulary Purpose. The idea is that in every group, an OG Vocabulary can be assigned a particular role. E.g., such and such vocabulary is for project release tagging.

Now I'm trying to work out a filter that allows me to specify the Purpose of a vocabulary, and solely as an exposed filter look up the local group's assigned vocabulary, populate a taxonomy selection widget, and proceed normally as a taxonomy filter.

But I seem to have done at least one thing wrong, because I get some fine errors on my effort to rename tid to tid_purpose as an alternate index.

EDIT: The form widgets generate fine, the query does not.

function og_vocab_purpose_views_data_alter(&$data) {
  // This handler is dependent on Spaces OG.
  if (!module_exists('spaces_og')) {
    return array();
  }
  $data['term_node']['tid_purpose'] = array(
    'group' => t('Taxonomy'),
    'title' => t('Term ID by Purpose'),
    'help' => t('The taxonomy term id, restricted by vocabulary purpose.'),
    'filter' => array(
      'handler' => 'og_vocab_purpose_handler_filter_term_node_tid',
      'hierarchy table' => 'term_hierarchy',
      'numeric' => TRUE,
      'skip base' => 'term_data',
      'allow empty' => TRUE,
    ),
  );
}

How do I wrap another plugin inside my plugin in this way?

Comments

Solution:

Grayside's picture

Solution: Use

<?php
$data
['term_node']['tid_purpose'] = array(
 
'real_field' => 'tid',
?>

Views Developers

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: