Skip to content

Instantly share code, notes, and snippets.

@bangpound
Created March 29, 2010 17:49
Show Gist options
  • Save bangpound/348166 to your computer and use it in GitHub Desktop.
Save bangpound/348166 to your computer and use it in GitHub Desktop.
<?php
// This theme prepreocess function brands node types in specific views
// with the site name.
function alshabaka_policybriefs_preprocess_views_view_field(&$vars, $hook) {
// Use a switch statement because I may need to alter other fields too.
switch ($hook) {
case 'views_view_field__alshabaka_frontpage__type':
case 'views_view_field__alshabaka_frontpage_bottom__type':
// I know this t() function call is utter nonsense.
$value = t('@site @type', array(
'@site' => variable_get('site_name', 'Drupal'),
'@type' => $vars['field']->original_value,
));
if ($hook == 'views_view_field__alshabaka_frontpage__type') {
// In this view, the field is excluded and used in the altered output of
// another field later in the list.
$vars['field']->last_render = $value;
}
else {
// In other views, the field is not excluded and is rendered through its
// own regular theme functions.
$vars['output'] = $value;
}
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment