Add authors and date to paragraph title template rather than field template

Ref #239
This commit is contained in:
Keegan Rankin 2023-07-13 16:34:54 -07:00
parent 31a43c1890
commit eeadf9a0b6

View file

@ -142,13 +142,8 @@ function agarica_languague_switch_link() {
/**
* Implements hook_preprocess_HOOK() for field__field_title template.
*/
function agarica_preprocess_field__field_title(&$variables) {
$parentEntity = $variables['element']['#object']->getParentEntity();
if ($parentEntity instanceof EntityInterface && $parentEntity->getEntityTypeId() === 'node') {
if (isset($parentEntity->getFields()['field_authors'])) {
$variables['authors'] = $variables['element']['#object']->authors_html;
$variables['date'] = $variables['element']['#object']->date_html;
}
}
function agarica_preprocess_paragraph__title(&$variables) {
$field_title = $variables['content']['field_title']['#object'];
$variables['authors'] = $field_title->authors_html;
$variables['date'] = $field_title->date_html;
}