Create new authority type

The aim of this page is to sum up all the steps required for creating a brand new, fully working authority type. Tested on a MARC21 DOM-indexed setup, it should work for UNIMARC DOM too (unless otherwise specified at some points).
We will create an authority type for publishers in our example.
== MARC authority framework ==
Create the new MARC authority framework from Home › Administration › Authority types. Enter a code for the framework (Authority type) and a string describing what this authority index is about (Description), e.g. PUBL and Publisher
Choose the field for the heading in the authority record (Authority field to copy) and then add it in the MARC structure page (e.g. 190).
== AuthoritiesMarc.pm ==
#Add the new heading field and authority type to GuessAuthTypeCode in /usr/share/koha/lib/C4/AuthoritiesMarc.pm (190 and PUBL in our case). 
#(Optional). The display of search result, in authority is done inside the routine "BuildSummary" that is present in AuthoritiesMarc.pm. There is a default display but it use only subfield $a. So if you want a different display, you need to change the code of this routine.
== MARC bibliographic framework ==
Go to Home › Administration › MARC frameworks and add a subfield $9 to the field of the MARC bibliographic framework who will be linked to the authority record (MARC21 260$9/UNIMARC 210$9). As for the basic and advanced constraints, you can refer to those in 100$9 (MARC21) or 700$9 (UNIMARC) as a sample.
Next, set the respective Thesaurus (in Other options box) for the subfield that will contain the heading (MARC21 260$b/UNIMARC 210$c in our example).
== Zebra ==
Add a section for the publisher to /etc/koha/zebradb/authorities/etc/bib1.att
 # Publisher
 att 1018 Publisher
 att 9052 Publisher-heading
(9052 being the first available number -in this case- for the new attribute Publisher-heading)
Add the linking of the subfield just created to /etc/koha/zebradb/marc_defs/<yourMarcFlavor>/biblios/record.abs, for example (MARC21):
 melm 260$9 Koha-Auth-Number 
Set the headings for the new authority type in /etc/koha/zebradb/marc_defs/<yourMarcFlavor>/authorities/record.abs, for example:
 # Publisher
 melm 190$a Publisher-heading:w,Publisher-heading:p,Publisher-heading:s,Publisher:w,Publisher:p,Heading:w,Heading:p,Heading:s,Heading-Main:w,Heading-Main:p,Heading-Main:s,Match:w,Match:p,Match-heading:w,Match-heading:p
 melm 190 Publisher:w,Publisher:p,Publisher:s,Heading:w,Heading:p,Heading:s,Match:w,Match:p,Match-heading:w,Match-heading:p
Edit /etc/koha/zebradb/ccl.properties:
 #Name-publisher 1018 The organization responsible 260$b
 # for the publication of the
 # item.
 Publisher 1=Publisher
 pb Publisher
 Publisher-heading 1=Publisher-heading
Add a new section to /etc/koha/zebradb/marc_defs/<yourMarcFlavor>/authorities/authority-koha-indexdefs.xml:
 
 
 <kohaidx:index_subfields tag="190" subfields="abcdefghjklmnopqrstvxyz">
 <kohaidx:target_index>Publisher:w</kohaidx:target_index>
 <kohaidx:target_index>Publisher:p</kohaidx:target_index>
 <kohaidx:target_index>Publisher:s</kohaidx:target_index>
 </kohaidx:index_subfields>
 <kohaidx:index_heading tag="190" subfields="abcdefghjklmnopqrstvxyz" subdivisions="vxyz">
 <kohaidx:target_index>Publisher-heading:w</kohaidx:target_index>
 <kohaidx:target_index>Publisher-heading:p</kohaidx:target_index>
 <kohaidx:target_index>Publisher-heading:s</kohaidx:target_index>
 <kohaidx:target_index>Heading:w</kohaidx:target_index>
 <kohaidx:target_index>Heading:p</kohaidx:target_index>
 <kohaidx:target_index>Heading:s</kohaidx:target_index>
 </kohaidx:index_heading>
 <kohaidx:index_heading tag="190" subfields="a">
 <kohaidx:target_index>Heading-Main:w</kohaidx:target_index>
 <kohaidx:target_index>Heading-Main:p</kohaidx:target_index>
 <kohaidx:target_index>Heading-Main:s</kohaidx:target_index>
 </kohaidx:index_heading>
 <kohaidx:index_match_heading tag="190" subfields="abcdefghjklmnopqrstvxyz" subdivisions="vxyz">
 <kohaidx:target_index>Match:w</kohaidx:target_index>
 <kohaidx:target_index>Match:p</kohaidx:target_index>
 <kohaidx:target_index>Match-heading:p</kohaidx:target_index>
 <kohaidx:target_index>Match-heading:s</kohaidx:target_index>
 </kohaidx:index_match_heading>
Then process it:
 xsltproc /etc/koha/zebradb/xsl/koha-indexdefs-to-zebra.xsl /etc/koha/zebradb/marc_defs/<yourMarcFlavor>/authorities/authority-koha-indexdefs.xml > /etc/koha/zebradb/marc_defs/<yourMarcFlavor>/authorities/authority-zebra-indexdefs.xsl
== Search.pm ==
Open /usr/share/koha/lib/C4/Search.pm and add the new index (Publisher-heading) to @indexes in getIndexes.
== Reindexing ==
Lastly, restart Zebra and do a full reindex for the authorities.
 sudo koha-restart-zebra <yourInstance>
 sudo koha-rebuild-zebra -a -f -v <yourInstance>
Category:MARC_Authority_data_support_RFCs