From 96e9bb5295899b7aec73562dac55c7013d664537 Mon Sep 17 00:00:00 2001 From: Rosie Le Faive Date: Fri, 26 Sep 2025 10:13:22 -0300 Subject: [PATCH] First commit. --- alter_mods_template.info.yml | 5 + alter_mods_template.module | 29 ++++ ...ld-contributor-description--data.html.twig | 1 + ...-contributor-name-and-role--data.html.twig | 1 + templates/mods.html.twig | 151 ++++++++++++++++++ .../paragraph--contributor--data.html.twig | 1 + 6 files changed, 188 insertions(+) create mode 100644 alter_mods_template.info.yml create mode 100644 alter_mods_template.module create mode 100644 templates/field--field-contributor-description--data.html.twig create mode 100644 templates/field--field-contributor-name-and-role--data.html.twig create mode 100644 templates/mods.html.twig create mode 100644 templates/paragraph--contributor--data.html.twig diff --git a/alter_mods_template.info.yml b/alter_mods_template.info.yml new file mode 100644 index 0000000..1d1e937 --- /dev/null +++ b/alter_mods_template.info.yml @@ -0,0 +1,5 @@ +name: Alter Mods Template (PWC) +description: "Alters the MODS template for OAI-PMH" +package: Custom +type: module +core_version_requirement: ^10.3 || ^11 diff --git a/alter_mods_template.module b/alter_mods_template.module new file mode 100644 index 0000000..e9bb442 --- /dev/null +++ b/alter_mods_template.module @@ -0,0 +1,29 @@ + [], + 'field__field_contributor_name_and_role__data' => [], + 'field__field_contributor_description__data' => [], + ]; +} + +function alter_mods_template_theme_suggestions_field(array $variables) { + $suggestions = []; + $field = $variables['element']['#field_name']; + $view_mode = $variables['element']['#view_mode']; + $suggestions[] = 'field__' . $field . '__' . $view_mode; + if ($variables['element']['#view_mode'] == 'data') { + # dump($variables); + } + return $suggestions; +} diff --git a/templates/field--field-contributor-description--data.html.twig b/templates/field--field-contributor-description--data.html.twig new file mode 100644 index 0000000..04103f5 --- /dev/null +++ b/templates/field--field-contributor-description--data.html.twig @@ -0,0 +1 @@ +{{ element }} diff --git a/templates/field--field-contributor-name-and-role--data.html.twig b/templates/field--field-contributor-name-and-role--data.html.twig new file mode 100644 index 0000000..c77d2e1 --- /dev/null +++ b/templates/field--field-contributor-name-and-role--data.html.twig @@ -0,0 +1 @@ +{{ element[0]['#prefix'] | trim | lower }}{{ element[0]['#entity'].bundle }}:{{ element[0]['#plain_text'] }} diff --git a/templates/mods.html.twig b/templates/mods.html.twig new file mode 100644 index 0000000..a75d9ff --- /dev/null +++ b/templates/mods.html.twig @@ -0,0 +1,151 @@ + + + + {{ elements.title }} +{% if elements.subtitle is not empty%} {{ elements.subtitle }}{% endif %} + +{% for name_info in elements.names | split ('|') %} +{% set name_info = name_info | split(':', 3) %} +{% set name__role = name_info[0] | trim | lower %} +{% set name__type = name_info[1] | replace({"corporate_body":"corporate"}) | raw %} +{% set name_info = name_info[2] | split("~", 2) %} +{% set name__name = name_info[0] | trim %} +{% set name__description = name_info[1] | trim %} +{% if name__name is not empty %} + + {{ name__name }} + + {{ name__role }} + +{% if name__description is not empty %} + {{ name__description }} +{% endif %} + +{% endif %} +{% endfor %} +{% if elements.typeofresource is not empty %}{{ elements.typeofresource }} +{% endif %} +{% if elements.genre is not empty %}{{ elements.genre }} +{% endif %} +{% if elements.abstract is not empty %}{{ elements.abstract }} +{% endif %} +{% if elements.language_iso6392b is not empty %} +{% for language in elements.language_iso6392b | split ('|') %} + + {{ language | trim }} + +{% endfor %} +{% endif %} + +{% if elements.publisher is not empty %} {{ elements.publisher }} +{% endif %} +{% if elements.published_place is not empty %} + + {{ elements.published_place }} + +{% endif %}{% if elements.published_place_marccountry is not empty %} + {{ elements.published_place_marccountry }} + +{% endif %} +{% if elements.dateissued_edtf is not empty %} {{ elements.dateissued_edtf }} +{% endif %} +{% if elements.datecreated_edtf is not empty %} {{ elements.datecreated_edtf }} +{% endif %} +{% if elements.datecopyright_edtf is not empty %} {{ elements.datecopyright_edtf}} +{% endif %} + +{% if elements.physicaldescription_form is not empty %}
{{ elements.physicaldescription_form }}
+{% endif %} +{% if elements.physicaldescription_extent is not empty %} {{ elements.physicaldescription_extent }} +{% endif %} +{% if elements.physicaldescription_note is not empty %} {{ elements.physicaldescription_note }} +{% endif %} +
+{% for topic in elements.subject_topic |split ('|') %} + + {{ topic|trim }} + +{% endfor %} +{% for geographic in elements.subject_geographic |split ('|') %} + + {{ geographic|trim }} + +{% endfor %} +{% for temporal in elements.subject_temporal |split ('|') %} + + {{ temporal|trim }} + +{% endfor %} +{% if elements.subjects_name is not empty %} +{% set name_type_info = elements.subjects_name_vocabulary|split('|') %} +{% for subject_name_info in elements.subjects_name |split ('|') %} +{% set name_type_info_x = name_type_info[loop.index0] | replace({"Person":"person", "Corporate Body":"corporate", "Family":"family", "Conference":"conference"}) | raw %} + + + {{ subject_name_info }} + + +{% endfor %} +{% endif %} + + + {{ elements.subject_hierarchicalgeographic_continent }} + {{ elements.subject_hierarchicalgeographic_country }} + {{ elements.subject_hierarchicalgeographic_state }} + {{ elements.subject_hierarchicalgeographic_province }} + {{ elements.subject_hierarchicalgeographic_region }} + {{ elements.subject_hierarchicalgeographic_county }} + {{ elements.subject_hierarchicalgeographic_island }} + {{ elements.subject_hierarchicalgeographic_city }} + {{ elements.subject_hierarchicalgeographic_citysection }} + + + + + {{ elements.subject_geographic_coordinates }} + + +{% if elements.relateditem_title is not empty %} + + + {{ elements.relateditem_title }} + + +{% endif %} +{% if elements.relateditem_collection_title is not empty %} + + + {{ elements.relateditem_collection_title }} + + +{% endif %} +{% if elements.accesscondition_restrictiononaccess is not empty%} + {{ elements.accesscondition_restrictiononaccess }} +{% endif %} +{{ elements.accesscondition_useandreproduction }} + + {{ elements.location_url }} + {% if elements.location_physical is not empty %} + {{ elements.location_physical }} + {% endif %} + +{{ elements.identifier_uri}} +{{ elements.identifier_local}} +{{ elements.identifier_ark}} +{{ elements.note }} + + {% if elements.recordinfo_note_coursecode is not empty %} + {{ elements.recordinfo_note_coursecode }} + {% endif %} + {% if elements.recordinfo_note_courseyear is not empty %} + {{ elements.recordinfo_note_courseyear }} + {% endif %} + {% if elements.recordinfo_note_courseterm is not empty %} + {{ elements.recordinfo_note_courseterm }} + {% endif %} + + {% if elements.recordinfo_cataloguing_language_iso6392b is not empty %} + {{ elements.recordinfo_cataloguing_language_iso6392b }} + {% endif %} + + diff --git a/templates/paragraph--contributor--data.html.twig b/templates/paragraph--contributor--data.html.twig new file mode 100644 index 0000000..f14cbff --- /dev/null +++ b/templates/paragraph--contributor--data.html.twig @@ -0,0 +1 @@ +{{ elements.field_contributor_name_and_role }}~{{ elements.field_contributor_description }}