function FieldPluginBase::tokenize_value in Views (for Drupal 7) 8.3
Replace a value with tokens from the last field.
This function actually figures out which field was last and uses its tokens so they will all be available.
3 calls to FieldPluginBase::tokenize_value()
- FieldPluginBase::element_classes in lib/
Drupal/ views/ Plugin/ views/ field/ FieldPluginBase.php - Return the class of the field.
- FieldPluginBase::element_label_classes in lib/
Drupal/ views/ Plugin/ views/ field/ FieldPluginBase.php - Return the class of the field's label.
- FieldPluginBase::element_wrapper_classes in lib/
Drupal/ views/ Plugin/ views/ field/ FieldPluginBase.php - Return the class of the field's wrapper.
File
- lib/
Drupal/ views/ Plugin/ views/ field/ FieldPluginBase.php, line 301 - Definition of Drupal\views\Plugin\views\field\FieldPluginBase.
Class
- FieldPluginBase
- Base field handler that has no options and renders an unformatted field.
Namespace
Drupal\views\Plugin\views\fieldCode
function tokenize_value($value, $row_index = NULL) {
if (strpos($value, '[') !== FALSE || strpos($value, '!') !== FALSE || strpos($value, '%') !== FALSE) {
$fake_item = array(
'alter_text' => TRUE,
'text' => $value,
);
// Use isset() because empty() will trigger on 0 and 0 is
// the first row.
if (isset($row_index) && isset($this->view->style_plugin->render_tokens[$row_index])) {
$tokens = $this->view->style_plugin->render_tokens[$row_index];
}
else {
// Get tokens from the last field.
$last_field = end($this->view->field);
if (isset($last_field->last_tokens)) {
$tokens = $last_field->last_tokens;
}
else {
$tokens = $last_field
->get_render_tokens($fake_item);
}
}
$value = strip_tags($this
->render_altered($fake_item, $tokens));
if (!empty($this->options['alter']['trim_whitespace'])) {
$value = trim($value);
}
}
return $value;
}