popsu.theme 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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. /*$rows = $variables['rows'];
  29. $style = $view->style_plugin;
  30. $options = $style->options;
  31. $variables['default_row_class'] = !empty($options['default_row_class']);*/
  32. /* foreach ($rows as $id => $row) {
  33. $variables['rows'][$id] = array();
  34. $variables['rows'][$id]['content'] = $row;
  35. $variables['rows'][$id]['attributes'] = new Attribute();
  36. if ($row_class = $view->style_plugin
  37. ->getRowClass($id)) {
  38. $variables['rows'][$id]['attributes']
  39. ->addClass($row_class);
  40. }
  41. }*/
  42. };