You are here

function template_preprocess_views_bootstrap_cards in Views Bootstrap 8.4

Same name and namespace in other branches
  1. 8.3 views_bootstrap.theme.inc \template_preprocess_views_bootstrap_cards()

Prepares variables for views cards templates.

Default template: views-bootstrap-cards.html.twig.

Parameters

array $vars: An associative array containing:

  • view: A ViewExecutable object.
  • rows: The raw row data.
1 string reference to 'template_preprocess_views_bootstrap_cards'
ViewsBootstrap::getThemeHooks in src/ViewsBootstrap.php
Returns the theme hook definition information.

File

./views_bootstrap.theme.inc, line 58
Preprocessors and helper functions to make theming easier.

Code

function template_preprocess_views_bootstrap_cards(array &$vars) {
  $view = $vars['view'];
  $vars['id'] = ViewsBootstrap::getUniqueId($view);

  // Card rows.
  $image = $view->style_plugin->options['card_image_field'];
  $title = $view->style_plugin->options['card_title_field'];
  $content = $view->style_plugin->options['card_content_field'];
  foreach ($vars['rows'] as $id => $row) {
    $vars['rows'][$id] = [];
    $vars['rows'][$id]['image'] = $view->style_plugin
      ->getField($id, $image);
    $vars['rows'][$id]['title'] = $view->style_plugin
      ->getField($id, $title);
    $vars['rows'][$id]['content'] = $view->style_plugin
      ->getField($id, $content);
  }
}