From e49ad3fc9cffd33e00156d6f3d54587aca4f51a7 Mon Sep 17 00:00:00 2001 From: naomi Date: Sat, 23 Jan 2021 18:12:35 +0000 Subject: [PATCH] Edited template to place "EVA" fields (embedded views) at the top of case page. --- modules/opencase_entities/oc_case.page.inc | 3 +++ modules/opencase_entities/templates/oc_case.html.twig | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/modules/opencase_entities/oc_case.page.inc b/modules/opencase_entities/oc_case.page.inc index 6de9601..a64da0e 100644 --- a/modules/opencase_entities/oc_case.page.inc +++ b/modules/opencase_entities/oc_case.page.inc @@ -23,12 +23,15 @@ function template_preprocess_oc_case(array &$variables) { // Separate the fields into two sections to be displayed in two columns. // Remove the name (title) field as this is displayed anyway. $variables['id'] = $variables['elements']['#oc_case']->get('id')[0]->get('value')->getValue(); + $variables['eva_fields'] = array(); // if the installation has any "EVA" (embedded view) fields this should catch them. $variables['base_fields'] = array(); $variables['other_fields'] = array(); foreach (Element::children($variables['elements']) as $key) { $variables['content'][$key] = $variables['elements'][$key]; if (in_array($key, ['created', 'changed', 'files', 'actors_involved', 'status', 'user_id'])) { $variables['base_fields'][$key] = $variables['elements'][$key]; + } else if (strpos($key, "entity_view") !== false) { + $variables['eva_fields'][$key] = $variables['elements'][$key]; } else { $variables['other_fields'][$key] = $variables['elements'][$key]; unset($variables['other_fields']['name']); diff --git a/modules/opencase_entities/templates/oc_case.html.twig b/modules/opencase_entities/templates/oc_case.html.twig index 50376f8..7232fdc 100644 --- a/modules/opencase_entities/templates/oc_case.html.twig +++ b/modules/opencase_entities/templates/oc_case.html.twig @@ -18,6 +18,11 @@

{{ title }}

+
+ {% for field in eva_fields %} + {{ field }} + {% endfor %} +
{{ base_fields.actors_involved }} {{ base_fields.changed }}