[Koha-devel] Formatting control number searches

Barton Chittenden barton at bywatersolutions.com
Thu May 24 21:15:01 CEST 2018


I'm working on generating links for 7XX linking fields in XSLT, a-la Bug
15140 - Add MARC21 776 to OPAC and staff display (
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=15140).

This Takes the 773$w, and uses the XSLT template 'extractControlNumber'
which strips the leading MARCOrgCode, e.g. turning
(OCoLC)2776588 into 2776588 ... and then the search URL is

/cgi-bin/koha/opac-search.pl?q=Control-number:2776588

The problem is that 2776588 isn't the actual OCLC number -- The formatting
rules are here:
https://help.oclc.org/Metadata_Services/OCLC-MARC_records/Content_designators_for_bibliographic_data/20Bibliographic_record_control_fields

In short: 0-8 digits: 0 pad to 8 digits, prepend 'ocm':

2776588 -> ocm02776588

9 digits, prepend 'ocn'

> 9 digits, prepend 'on'

I tried formatting the search with a leading '*':

/cgi-bin/koha/opac-search.pl?q=Control-number:*2776588

as well as with leading and trailing '*'

/cgi-bin/koha/opac-search.pl?q=Control-number:*2776588*

Neither of these worked.

Formatting the control number according to the OCLC rules above did work:

/cgi-bin/koha/opac-search.pl?q=Control-number:ocm02776588

So I have three questions:

1) Is there a way to format a Control-number search that doesn't force me
to generate the control number according to the OCLC rules above?

2) If not, does anyone have pointers about how to

* Test for (OCoLC) ->
  * Test length of control number
    * < 9 -> 0 pad to 8 digits, prepend 'ocm'
    * 9  -> prepend 'ocn'
    * > 9  -> prepen 'on'

3) Are there other control number formatting rules for other MARCOrgCodes?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.koha-community.org/pipermail/koha-devel/attachments/20180524/174fdf54/attachment.html>


More information about the Koha-devel mailing list