1

I want to set an extra class for the first page of a paged View.

/**
 * Implements hook_views_pre_render().
 */
function my_module_views_pre_render(ViewExecutable $view) {
  if ($view->id() === 'my_view' && $view->current_display === 'page_1') {
    // Somehow set/override the css class here.
  }
}

How can I change the CSS class set in the advanced settings of the View?

2

Something like this should do it:

$view->display_handler->setOption('css_class', 'your_class');

Good luck!

  • setOption is the correct method. Thanks! Are the options documented anywhere? – Tim Aug 10 '17 at 18:51
  • Yes, good catch. You need to look at DisplayPluginBase::defaultableSections() for a list of the options. – Stefanos Petrakis Aug 10 '17 at 23:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.