Services

  • Drupal CMS Developer
  • Website speed optimisation
  • Drupal 6 to Drupal 8 migrations

Welcome

Welcome, I am a Web Developer based in Madrid, Spain originally from the UK. I studied Computer Science & eBusiness at Loughborough University. I specialise in Content Management System websites

Drupal Views2 - Display all values if no results with exposed filter

I had an issue where I had a google map showing the locations of results, and a filter which helped you zoom in on locations. Basically you typed a location and the map showed the location of the results as well as some listings. However, if there were no results, instead of showing an empty page, I wanted the google map to appear with all results and an error message. What I did was set up an "Empty text" value which called a views function "views_embed_view()", I then created a block within that view but without the exposed filter (actually removing that filter all together).
In the Empty text value of the main view display I put...


<?php
echo views_embed_view("NAME OF VIEW","NAME OF DISPLAY",array("ARRAY OF VALUES IF I WANT TO PASS ANY","JUST REMOVE THIS PART IF YOU DO NOT WANT TO PASS ANYTHING"));
?>

Comments

Display Format

Be sure to change the Display format from HTML to PHP Code otherwise it won't work!