Would someone be able to help me figure out how to add another taxonomy mapping, please?

The "Series" mapping in millennium.module seemed closest to what I want to do, so I used it as my starting point. I have this so far:
// Resource Types
$tmpfields = millennium_getFields_fixed($marc, "902");
foreach ($tmpfields as $field) {
if ($tmpsub = millennium_getSubfield_firstvalue($field, "a")) {
// Fix/normalize data: trim, remove trailing punctuation
$resourcetype = millennium_trim_marc_value($tmpsub["data"]);
millennium_add_node_taxonomy_terms($nodeobject, variable_get('millennium_marc_vid_resourcetype', -1), array($resourcetype));
}
}

I've added $resoucetype to the $vocs and $descs arrays in millennium.admin.inc, and "millennium_marc_vid_resourcetype" to the $variables array in millennium.install.

I have a Resource Types taxonomy set up, and a Resource Types field in my content type pointing to that taxonomy, but whenever I try to import any of my test items, nothing goes into my Resource Types taxonomy.

Have I missed something? Any help would be greatly appreciated.

Karen S.

CommentFileSizeAuthor
#2 902-code-added.txt2.96 KBkarenruth73
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

karenruth73’s picture

After a bit more poking about, I think what I might actually need is updated documentation on how to create taxonomies for version 7+. I tried reverting to the original Series mapping and importing an item that I know has data in the 830 field and it still didn't map to the linked taxonomy.

karenruth73’s picture

FileSize
2.96 KB

Update: The catalogers have changed how the field I'm trying to map is entered in the ILS, so I don't think the Series section will work anymore. Now, the field looks more like the Subject field, with each entry on a separate line. And I would like the 902 field to import the same way the Subjects do, all the entries getting dumped into a taxonomy and the appropriate ones showing up in a term reference field in each node.

I've tried using the Subjects code from millennium.module to import the 902s but still can't get them into the taxonomy.

I've attached a text file with the various bits of code I've added to several files.

What am I missing? Any help would be appreciated.

Thanks.

Karen S.

janusman’s picture

Status: Active » Postponed (maintainer needs more info)

So, taking a look at the code... it's a bit hard to know where the bits and pieces go (normally I would have a patch file uploaded into this issue queue) to take a look. However, I kind of pieced together what you are trying to acheive.

The code does look fine *at first glance*, but to actually debug it would require: (a) a patch file I could apply to the module that contains only your changes, and (b) some sample direct URLs to sample items to test the changes on.

While it's good to extend the functionality you want to the base module, if I understand correctly, this is a local field determined by the library, so probably not something we can map to everyone...? If you think this would be useful for everyone, please explain why so I can understand better.

Now... if this is a one-off thing just for your library's situation: normally you would implement a hook in a custom module that would add the necessary items into the node object at importing time.

The code kind of self-documents this (sorry if it's hidden... it's inside the millennium_record_to_nodeobject() function:

  // Let other modules alter the node object
  //  function signature: mymodulename_millennium_nodeobject_alter($nodeobject, $parsed_marc)
  //  where:
  //    $biblio is the biblio information array
  //    $parsed_marc is the parsed MARC record

So, you might get by by implementing a function like the above in a custom module and put all the logic in there. Basically the function you would write would alter the incoming $node object right before it's saved into the DB. Your function would add whatever data, taxonomy fields, node attributes/fields, etc. you'd like depending on the available $parsed_marc data.

karenruth73’s picture

Thanks, I'll try that.