#1397526: Add an option to select which search page facets link to when displayed on non-search pages
#1538620: Multiple environments each with facets on non-search pages
#1391850: Fatal error when Solr server is not available on non-search pages that are showing facet blocks
#1394136: Link non-search page facets to a search page rather than environment

These issues all touch on this subject and try to fix it but none of them do. The maintainers decided that allowing facets to submit to search pages other than the default would be complicated and possibly confusing (see https://drupal.org/node/1397526#comment-5458236). So they compromised on allowing facets to appear on the non-search pages but they'd always submit to the default search page. This has proved to be an issue for us. I'll explain the case and post the patch in a comment.

We have a search page setup on the path: 'providers/search' as well as a content type called Provider that aliases its content to 'providers/[node-title].' We want search facets to appear on all Provider nodes (ie. 'providers/*') - which are non-search pages. After configuring the facets and the facet blocks to display on the appropriate paths, the facets appear on the non-search pages. However, when you select a facet on one of these pages, it comes back with no results because all non-search page facets submit to the default site search, which is not the providers search.

Now we have also done some other customization here so I'm not exactly sure if the patch fixes the issue for all cases or if it just works for us because of our specific configuration + other patches. And I have no idea if this will break other functionality or if this has already been addressed in the 1.4 or 1.x-dev branches.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

dags’s picture

Status: Active » Needs review
FileSize
971 bytes

This patch should apply to the 1.3 release.

Status: Needs review » Needs work

The last submitted patch, apachesolr-nonsearchpage-facets-2103329-1.patch, failed testing.

dags’s picture

Status: Needs work » Needs review
FileSize
953 bytes

Woops. This patch should apply. It also fixes the path checking.

kleinmp’s picture

I am having the same issue and this fixes it nicely.

Nick_vh’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
Nick_vh’s picture

Nick_vh’s picture

Status: Needs review » Needs work
@@ -43,6 +43,18 @@ function apachesolr_search_init() {
+    foreach ($search_pages as $search_page => $settings) {
+      if (drupal_match_path($path, $search_page['search_path'] . '*')) {
+        $search_page = $settings;
+        $search_page_id = $search_page;
+        break;
+      }

This would only solve your use case where the path of the other pages where your facets appear are the same as your search page.

Perhaps we need a hook/alter to add some logic as to which search page you want to send it to?

I'd love your input here

dags’s picture

When I encountered this problem, my initial thought was that the user should be able to choose which search environment should be used on a per-path basis. I started working on a patch but it was getting a little messy so I opted to go with the patch in #3 simply because it worked for my case. But I still think it's more appropriate to choose the env. per-path. This is what I was going for before I abandoned the approach:

  1. Provide an additional "Facet behavior/configuration" settings page that decouples a facet's display settings from the way it behaves internally.
  2. Provide radio buttons per-path that allow the user to choose which environment that path should submit to. So for instance, if the user declares 3 non-search paths, there will be 3 sets of radio buttons, each containing the same options, and the user is allowed to choose one of them - with the default search environment being selected by default.

There may be better UI options than radio buttons but you get the idea. And of course we'd also need to store these settings in an additional variable.

dags’s picture

Issue summary: View changes

Updated issue summary.

kleinmp’s picture

FileSize
959 bytes

I am updating this patch because it was re-applied on a site that I was working on and it caused a bunch of php notices.

kleinmp’s picture

FileSize
1.54 KB

So this patch was slightly broken all along and once I fixed the php notices, it stopped working as intended on non-search pages. It still think the module should select the apachesolr search page that you're on instead of always using the default but I added a drupal_alter to the patch to make it more flexible.