I found http://drupal.org/node/1176080 which explains how to alter the title of a View, but it doesn't seem to work (especially in Views 7.x-3.x-dev). I have my title specified as "Studies: %1" which works fine except when there is no argument. If the argument is not present, I display all values and want the title to say "Studies: All". Can anyone help me fix this, please?
In hook_views_pre_render(), I have tried both of these options: $view->build_info['substitutions'] = array('%1' => t('All')); $view->build_info['title'] = str_replace('%1', t('All'), $view->build_info['title']); Neither worked; I still get "%1" displayed. Nancy Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
24 августа 2011, 17:17 от "Ms. Nancy Wichmann" nan_wich@bellsouth.net:
I found http://drupal.org/node/1176080 which explains how to alter the title of a View, but it doesn't seem to work (especially in Views 7.x-3.x-dev). I have my title specified as "Studies: %1" which works fine except when there is no argument. If the argument is not present, I display all values and want the title to say "Studies: All". Can anyone help me fix this, please?
In hook_views_pre_render(), I have tried both of these options: $view->build_info['substitutions'] = array('%1' => t('All')); $view->build_info['title'] = str_replace('%1', t('All'), $view->build_info['title']); Neither worked; I still get "%1" displayed. Nancy Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
I moved the code to the hook_views_post_build() and everything is fine. I guess pre_render is too late.
Nancy
Injustice anywhere is a threat to justice everywhere. -- Dr. Martin L. King, Jr.
From: Buratino I would make sure you can change the title at all, e.g. $view->build_info['title'] = 'Custom title';