Closed (duplicate)
Project:
Views (for Drupal 7)
Version:
6.x-2.x-dev
Component:
Views Data
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
4 Jan 2010 at 11:31 UTC
Updated:
14 Oct 2010 at 18:36 UTC
I'm trying to activate tokens in title and header.
For title I've done something like:
/**
* Implementation of hook_views_pre_execute()
*/
function hook_views_pre_execute(&$view) {
$title = &$view->display['default']->handler->view->display['page_2']->display_options['title']; // get reference
if (strpos($title, ']') !== FALSE
&& $title = token_replace_multiple($title, array('user' => $user))) {
drupal_set_title($title);
}
}
And it's working.
But when I'm trying to change header, it doesn't work.
/**
* Implementation of hook_views_pre_execute()
*/
global $user;
foreach ($view->display['default']->handler->view->display as $display => &$view_data) {
$header = &$view_data->display_options['header']; // get reference
if (strpos($header, ']') !== FALSE
&& $header = token_replace_multiple($header, array('user' => $user))) {
}
}
Why changes of header variable in $view variable using pre_execute are not applied into rendered view?
Comments
Comment #1
kenorb commentedOk, I've done it through preprocess_views_view:
Comment #2
merlinofchaos commentedNote that there is a patch that adds token support to Views. Having tokens in the title and text areas could be valuable.
Comment #4
mattgilbert commentedWhere's the patch?
Comment #5
stinky commentedSubscribe
Comment #6
kenorb commented#462654: Token integration with views
Comment #7
ergophobe commentedPatch mentioned in #2 is probably this one:
#811480: Additional tokens for views
But so far, still failing testing. I couldn't find any others.
See also
http://drupal.org/node/462654