By default, during the harvesting process, data coming from connector is directly copied into node fields, without any particular process. But you will certainly want to modify this "raw" data before they go into nodes. Harvest plugins deserve this purpose.
How does it work?
For every mapping you have defined you can associate a plugin. During the harvesting process, if a mapping is associated with a plugin, instead of just copying the data, the plugin will be called.
Plugin will then build the data and return it so this processed data will be copied into the field.
Opac module comes with some plugins:
Taxonomy plugin works only with 'Term reference' fields.
This plugin allow to link automatically the field with one (or more) term of a particular vocabulary, depending on the incoming data.
It has 2 configuration options:
- Field to match
- Allows you to choose on which vocabulary field it will try to find a matching
- No match rule
- What should it do when it do not find a corresponding term?
- Leave empty
- leave the field empty
- Create new term
- create a new term in the vocabulary and make a link to it
Url plugin works only with 'Link' fields (added by Link module)
It allows to wrap incoming data into an url. For search rebound for example.
You can define the title of the link and the url, using '!value' as a placeholder.
Incoming data contain a word, and you want to transform it to a link that will search this word on your Drupal site.
You can configure title to be "Search for '!value'" and url to be "/search/node/!value".
It will create a link Search for '!value'
This plugin allows to link biblios with authorities.
It only works with entityreference fields.
Incoming data should be an authority identifier. If this identifier is present in Drupal, biblio node will be linked to the appropriate authority.
This plugin simply replace all non-numeric characters by '0 characters so that the final value is valid integer.
How to declare a plugin
You only have to implement hook_opac_node_field_plugin_info(). This hook is documented in opac.api.php but here's a brief explanation.
A plugin is defined by at least 4 things:
- plugin name
- The name of plugin. It should be unique.
- The display name
- available callback
- A callback function that will say if the plugin is available for a given opac server and a given field
- value callback
- The most important one. This callback function will be responsible for building the data that will be stored into field.