Add authors and date to paragraph title template rather than field template
Ref #239
This commit is contained in:
parent
31a43c1890
commit
eeadf9a0b6
1 changed files with 4 additions and 9 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue