Module to override the OAI-PMH MODS template (using the override hook that's outlined in that module). It provides an alternate MODS template that works with Contributor Paragraphs - see setup of pwc.upei.ca for example usage.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

29 lines
961 B

<?php
function alter_mods_template_rest_oai_pmh_metadata_template_alter(array &$template) {
// Use my module's template file to render mods metadata.
if ($template['file'] == 'mods') {
// This would use the template path/to/mymodule/templates/mods.html.twig
// for mods metadata rendered in OAI-PMH.
$template['name'] = 'alter_mods_template';
}
}
function alter_mods_template_theme($existing, $type, $theme, $path) {
return [
'paragraph__contributor__data' => [],
'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;
}