You are here

public function ResponsiveViewsGrid::getCustomClass in Responsive Views Grid 8

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 "row" or "col".

Return value

string A space-delimited string of classes.

File

src/Plugin/views/style/ResponsiveViewsGrid.php, line 115

Class

ResponsiveViewsGrid
Style plugin to render each item in a grid cell.

Namespace

Drupal\responsive_views_grid\Plugin\views\style

Code

public function getCustomClass($result_index, $type) {
  $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);
}