You are here

public function ViewsBootstrapCards::getCustomClass in Views Bootstrap 8.3

Return the token-replaced row or column classes for the specified result.

Parameters

int $result_index: The delta of the result item to get custom classes for.

string $type: The type of custom grid class to return, either "card_group" or "card".

Return value

string A space-delimited string of classes.

File

src/Plugin/views/style/ViewsBootstrapCards.php, line 49

Class

ViewsBootstrapCards
Style plugin to render each item in an ordered or unordered list.

Namespace

Drupal\views_bootstrap\Plugin\views\style

Code

public function getCustomClass($result_index, $type) {
  if (isset($this->options[$type . '_class_custom'])) {
    $class = $this->options[$type . '_class_custom'];
    if ($this
      ->usesFields() && $this->view->field) {
      $class = strip_tags($this
        ->tokenizeValue($class, $result_index));
    }
    $classes = explode(' ', $class);
    foreach ($classes as &$class) {
      $class = Html::cleanCssIdentifier($class);
    }
    return implode(' ', $classes);
  }
  return '';
}