How to modify a view title in Drupal when the view returns no result


It is possible to check in a view if the no results behaviour is activated. You can do this by checking the $view->result array in the hook_views_pre_render.

* hook_views_pre_render
* @param type $view
function one_agency_views_pre_render(&$view) {
// This view contains a no results behaviour
// In case no results behaviour is activated, we need to change the title
if ($view->name == 'your_view_name' && $view->current_display == 'your_view_display_name') {
if (count($view->result) == 0) {
$view->build_info['title'] = "The title for the no results behaviour";


Geef een reactie

Vul je gegevens in of klik op een icoon om in te loggen. logo

Je reageert onder je account. Log uit / Bijwerken )


Je reageert onder je Twitter account. Log uit / Bijwerken )

Facebook foto

Je reageert onder je Facebook account. Log uit / Bijwerken )

Google+ photo

Je reageert onder je Google+ account. Log uit / Bijwerken )

Verbinden met %s