In Drupal 7 I did something like:
function mymodule_views_pre_render(&$view) { //dpm($view); if ($view->name == 'services') { $view->style_plugin->row_plugin->options['view_mode'] = variable_get('services_teaser'); } else if ($view->name == 'portfolio') { $view->style_plugin->row_plugin->options['view_mode'] = variable_get('portfolio_teaser'); } }
I don’t know how to set the view mode on the fly, in Drupal 8. The idea is to be able to select the view mode for the view from a configuration form, instead of doing it from the view form.
How do I achieve this?