Skip to content

Instantly share code, notes, and snippets.

@mootari
Created August 3, 2017 14:15
Show Gist options
  • Save mootari/290774c9f21ee95f5923a754bf5b8d9e to your computer and use it in GitHub Desktop.
Save mootari/290774c9f21ee95f5923a754bf5b8d9e to your computer and use it in GitHub Desktop.
Drupal 7, Views: Alter field output in table display.
<?php
/**
* Implements hook_preprocess_HOOK().
*
* Marks projects that have a reference in content overview.
*/
function MODULE_preprocess_views_view_field(&$vars) {
if(!empty($vars['view']->MODULE_foo) && $vars['field']->field_alias === 'node_type') {
if(!empty($vars['view']->MODULE_foo[$vars['row']->nid])) {
$suffix = ', <i>with SUFFIX</i>';
$vars['output'] .= $suffix;
// Views tokens use the value from views_field_handler::$last_render.
$vars['field']->last_render .= $suffix;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment