function Grid::getCustomClass

Same name in other branches
  1. 9 core/modules/views/src/Plugin/views/style/Grid.php \Drupal\views\Plugin\views\style\Grid::getCustomClass()
  2. 10 core/modules/views/src/Plugin/views/style/Grid.php \Drupal\views\Plugin\views\style\Grid::getCustomClass()
  3. 11.x core/modules/views/src/Plugin/views/style/Grid.php \Drupal\views\Plugin\views\style\Grid::getCustomClass()

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

core/modules/views/src/Plugin/views/style/Grid.php, line 111

Class

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

Namespace

Drupal\views\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);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.