Taxonomy and drupal-opac

In Drupal, taxonmy is the practice of classifying content. It allows you to create vocabularies in which you can add terms and link your content to this terms. To learn more about taxonomy visit the Organizing content with taxonomy page.

In drupal-opac, taxonomy also allows to link opac nodes with terms. This terms can be any values you want such as biblio subjects, authors, publisher or document types. The only difference is that we need a way to automatically link an opac node field to a term when harvesting records. Drupal-opac enable that.

First let's see how to link a node to a vocabulary/term by hand. Go to "Admin > Structure > Taxonomy" and click on "Add vocabulary". Name: type "Subjects", Description: "Opac subjects" and save. Now click on the "Add terms" link of the newly created vocabulary and fill out the form to create a term named "Political Science" for exemple and save.
Go back to your opac content type manage fields page ("Admin > Structure > Content types" and click on manage fields link). Create the following field:

  • Label: Subjects
  • Field name: biblio_subjects
  • Field type: Term reference
  • Widget: Select list

Save, and on the next page, select the previously created vocabulary in the "Vocabulary" dropdown list: Subjects. Save. In the next page (which is the last), just change the "Number of values" to "Unlimited" because a book can have more than one subject.

To finish linking our new term with a node you have edit one. Show the one you want and click on the "edit" tab (you must have the permissions). In the form, search the "Subjects" dropdown list and select the term we have created. Save. You can repeat this operation for others nodes and/or add more terms. If you go back to the view mode of this node (view tab), you can see that it appears as a link. Cliking on the "subjects" link redirect you to a page listing all nodes related to this terms.

Create and link terms to node is well but now we must make drupal-opac doing it for us when haversting records. The first way to do that is to tell drupal-opac to create new term or to link with an existing for fields that are related to a vocabulary. How does it work ?

When drupal-opac import a biblio record from an ILS server, it apply the defined mapping by copying incoming remote fields in the corresponding one of the drupal node. But when the node field is related to a vocabulary drupal-opac make the following:

  • Get the vocabulary. With which vocabulary the node field is related to. In our example when applying mapping for the 'subjects' field, the module will find that it is related to 'Subjects' vocabulary. And then, it retrieves the list of terms for this vocabulary.
  • Check if the value of the incoming records subjects fields exists in the terms list.
  • If yes, it link the node field to this terms.
  • If not, behavior depends on the value of 'no match rule' in the mapping configuration
    • If 'no match rule' equal 'Leave empty' drupal opac do nothing and then let the field empty. However, if the field has a default value, it will be used.
    • If 'no match rule' is set to 'Create new term' drupal-opac will add a term to the 'subjects' vocabulary and link it to the node field.

We know how it works, now let's practice with the mapping form. Go back to the mapping form of the server and content type of your choice. On the unmapped fields part, click the subjects fields you have created before. You can note that in the mapping editing form a new section named 'Taxonomy rule for the_vocabulary' appeared below the mapping section. Note that the section title include the vocabulary name the field we are mapping is related to. That means drupal-opac knows it.
Here are 2 things to set:

  • Term field to compare: We will see later that we can add fields on a vocabulary/term. For the moment, just remember that the value of a term is in its name field. So, it is that we want to compare with the incoming field value. Then select term name.
  • No match rule: This means: what to do if the incoming field value not equals an existing term for the corresponding voacabulary. If you set 'Leave empty', drupal opac will do nothing. Else if you set 'Create new term' then drupal-opac will create a new one and link it the field.

You can save to return to biblio mapping overview page. Look at the mapped field table, you should see the just created mapping with taxonomy rule.
Launch a new harvest to update opac nodes and watch the result. See harvest records section if you forgot how to do that.

Using taxonomy for codified values

We just see how to create rules that automatically link our taxonomy fields with terms during harvest process. This is quite a bit simple because we just compare the incoming field value with existing terms. But what about an incoming field that would have a value such as "001" or "BK" that would be some codes and not the label. This is very common when retrieving document type or language field of a record. Indeed, ILS services could send 'EN' instead of 'English' for language field or 'BK' instead of 'Book' for document type field. This is quite a bit annoying because we don't want displaying the code (of a language, a document type etc ...) but the human value

Goog news ! Drupal-opac module provides a way to transform this codes by making them ... taxonomy terms. This works almost the same way than link a value to term but with a difference: We will add a field to the related vocabulary. Adding a field to a vocabulary is like adding a field to a content type. For example, when adding a field named 'location' to a content type, you get the possibility to create nodes (of this type of course) with location value(s). Then, adding a field named 'code' to a vocabulary give the possibility to create term with a code in addition to the default 'name' field.

The first thing you have to do is to create a new vocabulary. In the following example we consider that we will create a taxonomy on a language field for our opac nodes. So, create the vocabulary like we did in the previous section with the 'Language' name. Once you are done, edit this vocabulary and click in the "manage fields" link. Here, add a field like you would have done for a content type. Name it like you want, but a label such as 'Code' and a name such as 'field_code" would be better. The type should be text and the widget text field.
Now, add terms to this vocabulary. This is the main difference with simple taxonomy mappy: Terms should exist and we can't let drupal-opac create new one because code/label couple are predefined and can not be an arbitrary value. You have to create the list according to your ILS configuration. I have the following:

  • term 1: code: EN, name: English
  • term 1: code: FR, name: French
  • term 1: code: SP, name: Spanish
  • etc ...

Go to the manage fields page of your opac content type and create a field named 'Language' of Term reference type and link it to the language vocabulary (Like we already did before for subjects). Once it's ok go the biblio mapping overview page of your server and, in the unmapped fields list, click on the language one we have just created. In the mapping section select the corresponding field of the ILS connector. In the "Taxonomy rule" section of the form, select the code field as Term field to compare and "Leave empty" as No match rule and save your work.

You can launch an harvest to update your nodes and watch the result.