Created
July 8, 2013 13:55
-
-
Save steffenr/5948971 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Override variables used in views template for fields. | |
* | |
* @see views-view-fields.tpl.php | |
*/ | |
function theme_preprocess_views_view_fields(&$vars) { | |
// Until http://drupal.org/node/939462 lands for Drupal 7 we need to specify | |
// the specific preprocess functions ourself. | |
$preprocess_names = array(); | |
$preprocess_names[] = sprintf('%s__%s', __FUNCTION__, $vars['view']->name); | |
$preprocess_names[] = sprintf('%s__%s__%s', __FUNCTION__, $vars['view']->name, $vars['view']->current_display); | |
// Call more specific preprocess functions. | |
foreach ($preprocess_names as $function) { | |
if (function_exists($function)) { | |
call_user_func_array($function, array(&$vars)); | |
} | |
} | |
} | |
/** | |
* Override variables used in views template for a single field. | |
* | |
* @see views-view-field.tpl.php | |
*/ | |
function theme_preprocess_views_view_field(&$vars) { | |
// Until http://drupal.org/node/939462 lands for Drupal 7 we need to specify | |
// the specific preprocess functions ourself. | |
$preprocess_names = array(); | |
$preprocess_names[] = sprintf('%s__%s', __FUNCTION__, $vars['view']->name); | |
$preprocess_names[] = sprintf('%s__%s__%s', __FUNCTION__, $vars['view']->name, $vars['view']->current_display); | |
$preprocess_names[] = sprintf('%s__%s__field_%s', __FUNCTION__, $vars['view']->name, $vars['field']->options['id']); | |
$preprocess_names[] = sprintf('%s__%s__%s__%s', __FUNCTION__, $vars['view']->name, $vars['view']->current_display, $vars['field']->options['id']); | |
// Call more specific preprocess functions. | |
foreach ($preprocess_names as $function) { | |
if (function_exists($function)) { | |
call_user_func_array($function, array(&$vars)); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment