开发者

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? M开发者_如何转开发aybe it is possible by showing 2 separate views within one page, but how to pass the parameters? Any help will be appreciated.


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!


Create a Page view, and the Gmap can be a Block display view. Then you can add the Block to a region, and set the display path to the same value as your Page.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜