Advertising sustains the DA. Ads are hidden for members. Join today

Modify views output at field level

Last updated on
30 April 2025

This is how we can modify view output at field level

There is issue with theme_views_view_field($vars) API that when we implement this we will get error like
views-view-list.tpl.php (File not found, in folder ./), issue reference http://drupal.org/node/363182

We can avoid that issue by overriding function in our template.php. Function name would be THEMENAME_views_view_field__VIEWID__DISPLAY__FIELDNAME

function THEMENAME_views_view_field__VIEWID__DISPLAY__FIELDNAME($vars) {

}

EXAMPLE:
function mytheme_views_view_field__myviewid__page__myfield($vars) {
  // This will  modify output  for field "myfield" in view id "myview" for "page" display. Apply your logic here.
  $output = 'THIS IS MY FIELD VALUE';
  return $output;
}

Help improve this page

Page status: Not set

You can: