Drupal 8 - access field value in preprocess views view unformatted hook:
/**
* Implements hook_preprocess_views_view().
*/
function yourmodule_preprocess_views_view_unformatted(&$vars) {
if ($vars['view']->id() == 'solr_product_search') {
$vars['base_url'] = \Drupal::request()->getSchemeAndHttpHost();
if ($vars['view']->id() == 'solr_training_search') {
$view = $vars['view'];
$rows = $vars['rows'];
foreach ($rows as $rowId => $row) {
foreach ($view->field as $fieldId => $fieldValue) {
if ($fieldId == 'field_coursedate') {
$data = trim(strip_tags($view->style_plugin->getField($rowId, $fieldId)));
$vars['field_course_date'] = $data;
}
}
}
}
}
}
HAPPY CODING...
No comments:
Post a Comment