popsu.theme 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /*
  3. * @files
  4. * Theme Template Funtions
  5. */
  6. use Drupal\Core\Template\Attribute;
  7. /* implements template_preprocess_views_view_unformatted() */
  8. function popsu_preprocess_views_view_unformatted(&$variables) {
  9. $view = $variables['view'];
  10. if($view->id() == "programmes"){
  11. $rows = $variables['rows'];
  12. foreach ($rows as $id => $row) {
  13. $variables['rows'][$id]['attributes'] = new Attribute();
  14. $c = $variables['rows'][$id]['content']["#row"]->nid;
  15. $variables['rows'][$id]['attributes']->addClass("popsu-node-".$c);
  16. //kint($variables['rows'][$id]['content']["#row"]->nid);
  17. }
  18. }else{
  19. if ($view->current_display == "block_1") {
  20. $rows = $variables['rows'];
  21. foreach ($rows as $id => $row) {
  22. $variables['rows'][$id]['attributes'] = new Attribute();
  23. $c = $variables['rows'][$id]['content']["#row"]->nid;
  24. $variables['rows'][$id]['attributes']->addClass("popsu-node-".$c);
  25. }
  26. }
  27. }
  28. };
  29. /* implements template_preprocess_region() */
  30. function popsu_preprocess_region(&$variables) {
  31. $r = $variables['region'];
  32. if (isset($variables['region'])) {
  33. $variables['attributes']['class'][] = $variables['region'].'_container';
  34. }
  35. }