Facets on non-search_api pages

Tech Notes

By mr snow on 13 September, 2013 - 17:36 (This is cross posted from here) I've looked high and low for a solution to my situation. I'm happy if someone can tell me that I've gone about this all wrong. The situation is that I needed facets on a non-search panels page. I've read a lot about how to do this and did have facets appearing (using various techniques but finally settling on Views Context). But the paths that the Facets used always inherited the Panels path. With the above patch in #3 this resolved correct to the Views path. Here is my method. The reason this patch works that this allows search_api_views to set the search_api_base_path. Why does this help? It's a View that is providing the context for the Facets. So to implement. Much of this is taken from http://drupal.org/node/1066278#comment-4405704. 1. Enable some modules. Views, Search API, Search views, Solr Search, Facet API, Search facets, Views content panes, Panels (views search_api search_api_views search_api_solr facetapi search_api_facetapi views_content panels) 2. Apply the patch above. 3. Create a Search API engine and configure the index. Set it indexing. 4. Enable and configure the Facets in Search API 5. Create a Views page for the results with a path. You could possibly create a Pane with a path too--not sure. 6. Expose the full text search as you like. It's not relevant to this project. 7. Also create a View mode (? or variant) as a Context (enable Views Content module to get this). Name this something easy to understand like Search API Views context. Also make sure that you are limiting the number of results (possibly to zero), not sorting or doing anything that costs CPU. Possibly enable caching (I've not yet checked). This doesn't provide the results--just the context for non-search pages. 8. Make sure that in the Context settings (for this view mode) you have Use Panel path set to No. This is what causes the View to pass in its own path to the search view rather than allowing it to pick up on the path set by the Panel. 9. Create a new Panels page or Mini panel. 10. Add the Views Search API Views context as the Context in the Panel (not required context Views, just regular context). 11. Add View Context to the panel. Select View row as the type. Put it at the top above Facets. I'm still figuring out how to hide the actual context. 12. Add the Facets to the panel. 13. Save and test the path. Without this patch the Facets will inherit the path from the Panel. With this patch they will correctly inherit the path from the View. Tags: search_api Drupal facets Views