From a14c093d172215ffc521136955c3531c0d773d5f Mon Sep 17 00:00:00 2001 From: Konstantinos Platis <konstantinos.platis@cern.ch> Date: Mon, 5 Nov 2018 10:11:30 +0100 Subject: [PATCH] Added automatic classes for Horizontal Boxes --- README.md | 0 cern_display_formats.module | 15 ++++++++------- src/Plugin/views/style/HorizontalBoxes.php | 12 +++++++----- 3 files changed, 15 insertions(+), 12 deletions(-) mode change 100644 => 100755 README.md diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/cern_display_formats.module b/cern_display_formats.module index 453dfb0..034db7e 100755 --- a/cern_display_formats.module +++ b/cern_display_formats.module @@ -3,6 +3,7 @@ \Drupal::moduleHandler()->loadInclude('cern_display_formats', 'inc', 'display_formats.theme'); use Drupal\views\ViewExecutable; +use \Drupal\views\Plugin\views\cache\CachePluginBase; /** * Implements hook_theme(). @@ -19,10 +20,10 @@ function cern_display_formats_theme($existing, $type, $theme, $path) { } - -//function cern_display_formats_views_pre_render(ViewExecutable $view) -//{ -//// $view->displayHandler->option['css_class'] = 'horizontal-boxes'; -//// ksm($view); -//// return $view; -//} +/** + * Implements hook_views_post_render(). + */ +function cern_display_formats_views_post_render(ViewExecutable $view, &$output, CachePluginBase $cache) { + ksm($view); + $view->display_handler->setOption('css_class','horizontal-boxes'); +} diff --git a/src/Plugin/views/style/HorizontalBoxes.php b/src/Plugin/views/style/HorizontalBoxes.php index 1c2eb0b..2706310 100755 --- a/src/Plugin/views/style/HorizontalBoxes.php +++ b/src/Plugin/views/style/HorizontalBoxes.php @@ -37,10 +37,12 @@ class HorizontalBoxes extends DefaultStyle protected $renderFields = true; -// public function defineOptions() { -// -// $options = parent::defineOptions(); -// ksm($options); -// } + protected function defineOptions(){ + $options = parent::defineOptions(); + $options['row_class'] = 'horizontal-boxes-row'; + $options['default_row_class'] = 'horizontal-boxes-row'; + ksm($options); + return $options; + } } \ No newline at end of file -- GitLab