popsu.theme 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. $rows = $variables['rows'];
  30. $style = $view->style_plugin;
  31. $options = $style->options;
  32. $variables['default_row_class'] = !empty($options['default_row_class']);
  33. */
  34. /*
  35. foreach ($rows as $id => $row) {
  36. $variables['rows'][$id] = array();
  37. $variables['rows'][$id]['content'] = $row;
  38. $variables['rows'][$id]['attributes'] = new Attribute();
  39. if ($row_class = $view->style_plugin
  40. ->getRowClass($id)) {
  41. $variables['rows'][$id]['attributes']
  42. ->addClass($row_class);
  43. }
  44. }
  45. */
  46. };
  47. /**
  48. * Implements hook_preprocess_block().
  49. */
  50. // function popsu_preprocess_block(&$variables) {
  51. // $t="t";
  52. // }