How to change the title of a drupal view via code

Submitted by matthew on June 1, 2011 - 8:32pm

If you have a view and you want to be able to programmatically change the title of, you can do it via views hooks in your custom module:

function customModule_views_pre_render(&$view) {
if ($view->name == 'view_name' && $view->current_display == 'display_id') {
// Here you can do any php you want to get the title you need for your view.
$view->build_info['title'] = "My custom title!"

Easy peasy huh?

What is Drupal?

Drupal - a completely free, open source content management system that many organizations are using today to provide for their needs. Drupal's many features and add-ons allow it to be used for a variety of website needs. Drupal is a good choice for today's organizations of any size because it is free, easy, and incredibly flexible.

Copyright ©, 2008-2010. All Rights Reserved Drupal theme by Kiwi Themes.