Mapping Taxonomy Terms Without Selecting Vocabulary

TKS - July 23, 2009 - 21:34
Project:Feed Element Mapper
Version:6.x-1.x-dev
Component:Code
Category:feature request
Priority:normal
Assigned:Unassigned
Status:active
Description

It would be tremendously helpful to able to map options->tags to taxonomy (taxonomy), without having to specify a particular vocabulary.

Use Case: Site migration, where the working set of terms and vocabularies have already be set up on the new site via http://drupal.org/project/taxonomy_xml. There's no need to be able to create new terms on the fly, only to make sure that existing categorization is preserved.

As feedapi_mapper_taxonomy.inc currently stands, one would have to customize the RSS feed to break out each vocabulary as a distinct element -- which is certainly possible, but...

I'm not sure whether it would be better to add this functionality to feedapi_mapper_taxonomy.inc itself, or to create a new mapper -- would welcome any suggestions from those who understand the nuts-and-bolts better than I do. But I do think this functionality would be helpful for lots of people -- not only for site migrations, but other cases where the destination site has a set list of terms spread across multiple vocabularies.

Two wrinkles that I can see:
1. As noted above, it would have to ignore terms that are pre-existing -- since there's be no destination vocabulary for newly created terms.

2. Since not all vocabularies are available to all content types, there could be terms that come through for "forbidden" vocabularies. But one could either ignore that restriction (with proper warnings), or possibly make it so that a term from a "forbidden" vocabulary would be ignored just like a non-existent term would. Either would work for my needs, but I'm not sure which would be preferable more broadly -- assuming both ways are even possible!

Thoughts? Thanks!

#1

alex_b - July 27, 2009 - 15:56
Version:6.x-1.0-beta12» 6.x-1.x-dev

Is the format that http://drupal.org/project/taxonomy_xml somehow a standard? If so, we could support it in parser_common_syndication (or it may be already exposed by parser_simplepie). Once the data from the xml feed is exposed, the taxonomy mapper could be expanded to import into vocabularies.

If the format is NOT a standard, I'd go for the custom route: create a custom parser that parses out the XML file (you may already have that if the format is not a standard) and then create a custom hook_feedapi_mapper() implementation to map the parsers result into taxonomy vocabularies.

Refer to feedapi_mapper.api.php in the feedapi_mapper directory for more documentation.

#2

TKS - July 28, 2009 - 04:04

I have no idea if taxonomy_xml's format is a standard of any sort, but I tend to agree that a custom mapper is probably preferable. (Adding this functionality to the main taxonomy mapper would require all sorts of config options that would muck up the UI, among other things.)

I'm going to experiment with a custom mapper, but in the meantime, there's a very easy way to break taxonomy terms up by vocabulary in a Drupal 5 RSS feed. I created a mini-module, called views_rss_vocabularies.module, with the following use of hook_nodeapi:

function views_rss_vocabularies_nodeapi(&$node, $op) {
  switch ($op) {
    case 'rss item':
      foreach ($node->taxonomy as $term) {
        $output[] = array('key'   => 'vocab'. $term->vid,
                      'value' => $term->name);
      }
      return $output;
  }
}

So in addition to the standard category output, where each term gets listed like:

<category domain="http://urlhere.com/term_path">Term Name</category>

You also get something like this:

  <vocab7>Term Name</vocab7>

...where the digit after "vocab" denotes the term's Vocabulary ID.

Thanks to Ian Ward (http://drupal.org/user/4736) for pointing me in the right direction on breaking these out.

#3

Summit - September 27, 2009 - 21:17

Subscribing, interested in this also. May be something for feedelement mapper version 2?
greetings, Martijn

 
 

Drupal is a registered trademark of Dries Buytaert.