Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Dear Experts,
Is there anyone to let me know how I can render fields value in themename_preprocess_views_view_list () template programmatically!?
I have tried this but it is not working:
themename_preprocess_views_view_list (&$variables) {
$view = $variables['view'];
$rows = $variables['rows'];
foreach ($rows as $id => $row){
print $view->result[$id]->field_name;
}
}
Thanks for any quick response
MahPari
Comments
Comment #2
priyarm CreditAttribution: priyarm commentedHi,
function themename_preprocess_views_view_list(&$variables) {
$view = $variables['view'];
$id = $view->storage->id();
$rows = $variables['rows'];
foreach ($rows as $rowId => $row) {
foreach ($view->field as $fieldId => $field) {
$field_output = $view->style_plugin->getFieldValue($rowId, $fieldId);
print_r($view->field[$fieldId]->label());
print_r($field_output);
}
}
}
Comment #3
renatogThank you very much for your help @priyarm.
Best,
Comment #4
renatog