I don't know if this is helpful for anyone, but since I took the time to figure it out, I thought I'd share.
I wanted users to be able to do a faceted search and have a map of their search results show up at the bottom when those results contained geographic data. Here's what I did to get it to work (pardon my verbosity, I'm trying to make this as accessible as possible):
- Apply the patch to the GMap module found at #623234: Views 2.7 - breaks field output - GMap marker info window (bubble) doesn't display fields correctly (so markers show up on a map view in views 2.7)
- Create a view of node data
- Add fields to display in map markers as well as lat/lon fields
- Add a filter for the node types that have geographic data
- Change the style to GMap, using the lat/lon fields
- Add an argument for Node ID - this part is important
- For "Action to take if argument is not present", select "Provide default argument"
- Select "PHP Code" for "Default Argument Type"
- Add the following PHP
- Make sure to check "Allow multiple terms per argument."
- Add a block view
$env = faceted_search_env_load(1);
$results = $env->load_results();
$pages = array();
foreach( $results as $result )
$pages[] = $result->nid;
$nodeids = implode( ",", $pages );
return $nodeids;
This block, when enabled on faceted search pages, will display only the nodes returned from the faceted search.
I realize that this could break if there were more than one faceted_search environment in play - it could be modified to include that case.
Comments
Block display tip
It also works nicely to configure the block to show only when the following PHP code returns true:
_
Excellent info-- thanks for posting. You should really consider posting this in the http://drupal.org/handbook/config/contribmodules section of the handbook!
Return Limits
It might also be useful to include a defined number of results to be returned. I believe the default is 10 which could of course be restrictive for both faceted search and mapping purposes.
$results = $env->load_results($limit = 100);
Not sure about unlimited though.
-chris
this. . .is amazing. . .
this. . .is amazing. . .
Thanks so much.
Works like a charm.
Apache Solr
We just switched from faceted search to apachesolr for our search. When I get a chance, I'll write up separately what I did for apachesolr, but basically it's the same as this except using the following php code:
thank you so much for sharing
thank you so much for sharing, i will try it in my wesite and i hope it can work fine.
thanks again.