[development] Views Filter Plugin: Abstracting Vocabulary

Adam B. Ross grayside at gmail.com
Fri Jul 16 06:33:46 UTC 2010


Lee, that seems to have been the magic.

Thank you very much.

On Thu, Jul 15, 2010 at 8:34 PM, Lee Rowlands <contact at rowlandsgroup.com> wrote:
>
> Hi Adam
> Have you tried
> $data['term_node']['tid_purpose'] = array(
>   'real field' => 'tid',
> ....
>
> This tops the
>
>     '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 ta
>
>
> On Thu, 2010-07-15 at 19:49 -0700, Adam B. Ross wrote:
>
> I am trying to dive into Views Plugin writing, and I suspect I've hit
> a deep end.
>
> I'm working on a module which builds on OG Vocabularies, with the aim
> of being able to assign a given group vocabulary to a particular
> purpose for that group. For example, you could define a "Waterfall"
> group vocabulary as a project management field for the group, and in a
> different group, use an "Agile" group vocabulary.
>
> As part of my use case, I need to be able to create an Exposed Filter
> that will make use of whichever group Vocabulary is assigned to the
> Purpose configured in the View itself. I am having trouble wrapping my
> head around how to do this.
>
> Using the Taxonomy TID filter, you can select a vocabulary and an
> interface widget. I want to select a Purpose and an interface widget,
> have it do nothing except as an exposed filter, and then a View
> displayed in a given group will route it's widget to the configured
> vocabulary.
>
> (Still working out how to describe this functionality.)
>
> At this point, I'm defining my handler like so:
>
> 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,
>     ),
>   );
> }
>
> But of course, it then tries to use tid_purpose as an actual field.
> Can't use "tid" as that's already taken...
>
> Any pointers on an approach, documentation, or modules with similar
> functionality would be greatly appreciated.
>
>


More information about the development mailing list