From dcf73818e34898bfb6336fa0d267716c98ac2aab Mon Sep 17 00:00:00 2001 From: bach Date: Tue, 19 Oct 2021 12:48:18 +0200 Subject: [PATCH] bug fixe in popsu.theme #1563 --- web/themes/custom/popsu/popsu.theme | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/web/themes/custom/popsu/popsu.theme b/web/themes/custom/popsu/popsu.theme index 90b618ad..27141a9e 100644 --- a/web/themes/custom/popsu/popsu.theme +++ b/web/themes/custom/popsu/popsu.theme @@ -43,12 +43,10 @@ function popsu_preprocess_field(&$variables){ $variables['attributes']['class'][] = 'crop'; } if($element["#field_name"] == "field_programme"){ - - foreach ($variables["items"] as $id => $item) { - $item['attributes']['class'] = new Attribute(); - $c = $item['content']['#options']['entity']->nid->getString(); - $item['attributes']->addClass("programme-".$c); - // kint($variables["items"]);die(); + foreach ($element["#items"]->getIterator() as $id => $item) { + $nid = $item->getValue()['target_id']; + $variables['items'][$id]['attributes']['class'] = new Attribute(); + $variables['items'][$id]['attributes']->addClass("programme-".$nid); } } }