My use case is a Panels Everywhere site that needs to have a global search block in the header. Since the site doesn't use regions and blocks, I can't just use search api page and search api block. I have to use an exposed filter on the search api view. Since the exposed filter is expecting to be on the same page as the view, the form path for the exposed filter is wrong.

Perhaps a better solution would be Search Api Panels module that adds search pages to the page manger in Ctools. It could work similar to Search Api Page module, it just would supply the page and block to page manager and panels.

This would be huge for people building pure panels sites, as right now I can't see a way to make this work without without writing a custom module to alter the exposed filter.

There's actually an app in the new Panopoly distro called Panopoly Search, which might be worth investigating, but since it's part of a distro something more generic designed for the Search Api would be awesome.

Comments

alanom’s picture

This would be very useful, for search forms in page manager panels as well as panels everywhere and the rest of the ctools / panels family.

This exact feature exists in the Apache Solr drupal module family ( see #1047630: Provide block for custom search pages), it would be good to see it in Search API too

alanom’s picture

Here's a workaround until panels support is implemented. Note that this is a generic workaround that works in most modules that don't support panels like this, but which can declare block/page combos, (these steps are slightly more complicated than usual due to a bug in the way paths are defined in one of the below modules).

  • Install two modules:
    • Search API Pages . This allows search pages to be defined for search indexes, and creates search box blocks for them (which, as blocks, can be used in Panels or Page Manager). We want the block without the page, so also install...
    • Page Manager Existing Pages (you might not need this if using Panels Everywhere, but it might save you some work replicating panels). This allows us to replace the Search API Pages page with a panels page we can configure in Page Manager. (here's a write-up of pm_existing_pages by dwerhner aka dereine of Views fame, so you know it's legit)
  • Create a search API page for your index (config > search & metadata > search API > search pages)
  • Create an 'Existing page' in Page Manager (structure > pages > existing pages), with the same path as your search page plus !input (e.g. my_search)
  • This slips a new page into the main Page Manager list, disabled by default. Enable it, edit adding views, facets etc.
  • Important note if you're displaying your search results in a view using the Search Api contextual filter: at time of writing, pages defined with Search Api Pages incorrectly tell Drupal that their path contains no wildcard placeholders (e.g. "my_search" rather than "my_search/%"), so ctools doesn't register the search terms as being part of the URL and won't pass them to the view even when told to pass all arguments - it doesn't register it as an argument. You have to force it to pass the argument the non-recommended way, using %1 (in the case of a path my_search/keywords), %2 (search/my_search/keywords), etc, in the 'Arguments' box when configuring the views panel in panels/page manager.
  • The search box block created by Search API Pages is available in Panels/Page Manger under "Miscellaneous" ("Search block: [Name of your search page]"). Use it, and it points searches to the panels search page defined using page manager (note that, at time of writing due to the above bug, it doesn't get the search terms passed to it so, when placed on a search page, it doesn't prepopulate with previously entered search terms
liquidcms’s picture

I did pretty much the same thing (thanks to alanomaly for the guide) using Search API Views integration to get my views search result into a panel pane. My only issue at the moment seems to be that panels doesn't see the exposed form block so i can't place the form above my search results.

liquidcms’s picture

this worked to get the Search API created block added to a panel pane above my views search results:

$block = block_load('views', '-exp-search_test_2-page_1');
print render(_block_get_renderable_array(_block_render_blocks(array($block))));
liquidcms’s picture

and i guess might need to do this for Facet blocks as well as they don't seem to work in Panels either.

alanom’s picture

If you a) are having trouble with search related blocks including Facets in panels, b) you're not using Context views and c) the problem blocks appear before your search results in the panel, this is a longstanding problem. I can't remember where the appropriate issue is, but you can find a step-by-step guide that might fix your problem here: http://drupal.stackexchange.com/questions/8932/search-api-panels-display...

liquidcms’s picture

sounded promising; but alas, it did not help.

- i added context display to my search api view
- was then able to add this context as a context to my page
- did see context content available (none of which i need) - although i guess i could have used this for the exposed filter instead of my 2 lines of block code
- adding Facet API blocks to content pane and they still do not show.

liquidcms’s picture

his solved it for me (sort of): #1392288: Using Facets on Search API Views blocks.. turns out i need to have facet blocks placed in a pane which is rendered "after" the pane with the search results is rendered. for me that meant moving them to a region to the right of the search results rather than the one on the left i was trying to place them in.

so possibly there is a trick here; maybe that was the thing with the context.. although it doesn't work. maybe if i have a duplicate of my search results added before the region on the left where i need to add my facet blocks? and then somehow not render it (which i suspect will break what i am trying to do).

i guess ideally there needs to be a weighting value supported by panels so that you can determine render order

liquidcms’s picture

whoo hoo.. ok this actually worked - i simply had to grab any of rht content from the Views Context group and place it "ahead" of where i wanted the facet blocks to go. i simply picked the Views attachment content as it was empty and didnt display anything.

all seems a little cludgy..l but works.. :)

liquidcms’s picture

Issue summary: View changes

run on

legolasbo’s picture

Issue summary: View changes
Status: Active » Closed (outdated)

This issue has not seen activity in over 2,5 years. I am therefore closing this issue to clean up the issue queue. Feel free to re-open and update this issue if you feel this issue is still relevant and of importance.