Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiple Styles within one View in Drupal

I am creating a search functionality in Drupal by exposing filters within View. The problem is that I would like to add also a Google Map that display the location of nodes, apart from the search results (node title and some other fields). I can easily do one or the other but I find it difficult to display both search results in a standard way and the map below it. The reason for that is that I cannot choose mmultiple styles within views - i.e. Gmap and HTML list. Any ideas how can I achieve that? Maybe it is possible by showing 2 separate views within one page, but how to pass the parameters? Any help will be appreciated.

like image 257
Vonder Avatar asked Jul 21 '10 19:07

Vonder


1 Answers

This is an interesting question. Its definitely doable.

The solution lies in creating a Views Attachment Display for the gmap style (just like Page Displays and Block Displays there are Attachment Displays). First google around and understand the concept of a views attachment and learn how to create a simple one.

When you create a Views attachment display you need to specify which display to "attach" your view too. Subsequently in the attachment settings make sure you set "Inherit Exposed Filters" to "yes".

Briefly here are the steps in serial order

  1. Create a Page View for your search results (Node title + other fields)
  2. Create your exposed filters in the Default Display (so that it is available to all Views displays)
  3. Create an attached view with the gmap style. Note that since the exposed filter was created in the default display it should be available in the attached view also
  4. Make sure the attached view is attached to the Page display you created in step 2
  5. Make sure the "Inherit Exposed Filter" setting is Yes for the views attachment.
  6. Profit!
like image 89
Sid Kshatriya Avatar answered Oct 07 '22 09:10

Sid Kshatriya