[Koha] How to show description of authorized value in facet? SOLVED
Michael Kuhn
mik at adminkuhn.ch
Fri Apr 7 10:12:57 NZST 2017
Hi
Today I wrote:
> Environment: Debian GNU/Linux 8 with Koha 16.11.04 (package installation)
>
> Our Koha catalogue contains MARC field 385 $a with content e. g. "KG",
> linked to category "Lesekategorie" containing authorized values for the
> target audience, e. g. value "KG" (description for staff client and OPAC
> is: "Kindergarten"). Instead of "KG" the OPAC shows "Kindergarten" as
> expected.
>
> Now I have recently added a new facet for MARC field 385 $a and the
> facet does show - only instead of the description ("Kindergarten"), the
> facet shows the authorized value "KG". How can it be achieved to show
> the description in the facet?
>
> As I see it is actually possible to show the description because the
> authorized values for standard category "LOC" are properly showing the
> descriptions. I tried to find out how this works in file
> "opac-facets.inc" but without success. Can anyone please give me a hint?
For the record:
Jens Weber found the following code in file
"/usr/share/koha/lib/C4/Search.pm":
# also, if it's a location code, use the name instead of the code
if ( $link_value =~ /location/ ) {
# TODO Retrieve all authorised values at once, instead of 1 query per
entry
my $av = Koha::AuthorisedValues->search({ category => 'LOC',
authorised_value => $one_facet });
$facet_label_value = $av->count ? $av->next->opac_description : '';
}
I copied this section and adapted it as follows:
# also, if it's a lesekategorie code, use the name instead of the code
if ( $link_value =~ /lesekategorie/ ) {
my $av = Koha::AuthorisedValues->search({ category =>
'Lesekategorie', authorised_value => $one_facet });
$facet_label_value = $av->count ? $av->next->opac_description : '';
}
After a restart of Koha (including Plack) now the created facet actually
shows the description ("Kindergarten") instead of the authorized value
"KG". Great!
Of course this change will have to be reconfigured with every update but
I guess it makes no sense to include this in the official Koha code...
Best wishes: Michael
--
Geschäftsführer · Diplombibliothekar BBS, Informatiker eidg. Fachausweis
Admin Kuhn GmbH · Pappelstrasse 20 · 4123 Allschwil · Schweiz
T 0041 (0)61 261 55 61 · E mik at adminkuhn.ch · W www.adminkuhn.ch
More information about the Koha
mailing list