Как выполнить свою preprocess функцию до основной
Задача — изменить порядок выполнения preprocess функций для шаблона views_view_field так, чтобы своя функция mytheme_preprocess_views_view_field() выполнялась до template_preprocess_views_view_field():
/**
* Implements hook_theme_registry_alter().
*/
function mytheme_theme_registry_alter(&$theme_registry) {
$preprocess_functions = $theme_registry['views_view_field']['preprocess functions'];
$key = array_search('template_preprocess_views_view_field', $preprocess_functions);
if ($key !== FALSE) {
// вставляем свою функцию до основной (http://stackoverflow.com/a/3797526/487326)
array_splice($preprocess_functions, $key, 0, array('mytheme_preprocess_views_view_field'));
// удаляем дубликаты
$preprocess_functions = array_unique($preprocess_functions);
$theme_registry['views_view_field']['preprocess functions'] = $preprocess_functions;
}
}
/**
* Preprocess function for theme_views_view_field().
*/
function mytheme_preprocess_views_view_field(&$vars) {
...
}
Написанное актуально для
Drupal 7
Комментарии:
Нету комментариев для вывода...