Change a title of a view block programmatically!
Just in case you are like me and find yourself wanting to change the title of a view programmatically, and can't figure out how, the (somewhat unintuitive) way is to hit the build_info, so you do this in your module:
<?phpfunction hook_views_pre_render(&$view) { // Some code to make sure you are changing the right title, say an if statement perhaps! $view->build_info['title'] = t("Your Brand New Title!");}?>
Soon this will not be necessary, as there will be a much easier method for accomplishing this included in Views sometime in the near future.
<?phpfunction hook_views_pre_render(&$view) { // Some code to make sure you are changing the right title, say an if statement perhaps! $view->set_title($fancy_new_title);}?>
Hope this helps!
Comments
Anonymous (not verified)
Thu, 11/10/2011 - 16:33
Permalink
So many cool Views hooks
Queries, fields, filters and other View information can be altered at runtime too using additional Views hooks.
http://drupalcontrib.org/api/search/7/hook_views_
-stevector