From 11a263e7f3d1efc9d3845d4f2c716d03c7b0b002 Mon Sep 17 00:00:00 2001 From: Oliver Goldschmidt <o.goldschmidt@tuhh.de> Date: Tue, 12 Jan 2021 21:59:42 +0100 Subject: [PATCH] makes MARC record field configurable (#1813) --- config/vufind/config.ini | 9 +++++++++ .../src/VuFind/RecordDriver/MarcReaderTrait.php | 14 +++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/config/vufind/config.ini b/config/vufind/config.ini index 9779d2d5130..57e421ad64b 100644 --- a/config/vufind/config.ini +++ b/config/vufind/config.ini @@ -1719,6 +1719,15 @@ jump_to_single_search_result = false ; punctuation, but this can be used when ISBD punctuation is absent (e.g. ", "). ;marcPublicationInfoSeparator = " " +; If you have a custom index, you might want to change the field where the full +; MARC record is supposed to be. The field will be checked and ignored, if it is +; not a valid index field or does not exist in the record or index schema. +; If you have multiple fields with MARC content, you may add all of them +; by using a comma sepated list. The first field is the preferred one, if it does not +; exist, the next ones are taken. +; (Default = "fullrecord") +preferredMarcFields = "fullrecord" + ; When displaying publication information from 260/264, this can be set to true ; to make 264 information completely replace 260 information. Default is false, ; which will display information from 260 AND 264 when both fields are populated. diff --git a/module/VuFind/src/VuFind/RecordDriver/MarcReaderTrait.php b/module/VuFind/src/VuFind/RecordDriver/MarcReaderTrait.php index dc6949998e8..e6df13517f5 100644 --- a/module/VuFind/src/VuFind/RecordDriver/MarcReaderTrait.php +++ b/module/VuFind/src/VuFind/RecordDriver/MarcReaderTrait.php @@ -58,7 +58,19 @@ trait MarcReaderTrait public function getMarcRecord() { if (null === $this->lazyMarcRecord) { - $marc = trim($this->fields['fullrecord']); + // Get preferred MARC field from config, if it is set and is existing + $preferredMarcFields = $this->mainConfig->Record->preferredMarcFields + ?? 'fullrecord'; + $preferredMarcFieldArray = explode(',', $preferredMarcFields); + $preferredMarcField = 'fullrecord'; + foreach ($preferredMarcFieldArray as $testField) { + if (array_key_exists($testField, $this->fields)) { + $preferredMarcField = $testField; + break; + } + } + + $marc = trim($this->fields[$preferredMarcField]); // check if we are dealing with MARCXML if (substr($marc, 0, 1) == '<') { -- GitLab