Browse Source

bug fixe in popsu.theme #1563

bach 2 years ago
parent
commit
dcf73818e3
1 changed files with 4 additions and 6 deletions
  1. 4 6
      web/themes/custom/popsu/popsu.theme

+ 4 - 6
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);
       }
     }
   }