7

I am trying to build a page with Search API and Panels. I have created my search views with contexts, but I am unable to view any facets in my panel page.

My facets show up in regular blocks, but they don't show up in panels regions.

I have been able to find information regarding this issue from this Search API Issue. Apparently the order of the way the view is placed in panels is the problem, and if I re-order my facets and views in Panels, the facets show up properly.

In comment #28 of this issue, there is a way to set up a context to be able to display the facets anywhere on a panel page, but the wording is very confusing.

EclipseGc actually gave me a quick walkthrough on how to do this the "proper" way. It takes a bit more time and effort but its a lot more flexible and effective (plus it works without having to try and figure out the order of blocks like above). The basics of it are:

  1. Create a context view for your display.
  2. Go to contexts in your panel and add a view context with your view.
  3. You will now have a new "view context" option when adding content to a region.
  4. Choose view row (this is where it gets a bit more complexed as you have to manually build grids etc using regions and rows and so forth).
  5. You can now add your facets using the miscellaneous content option in panels wherever you want in your panel!
  6. I had to use to the default view exposed forms as the context view exposed forms didnt want to inherit the path. These can also go wherever and work!

What is a "context view" and how do I add it? It is a ctools context? Or is it a new context in views, or is is a context having to do with the contexts module?

Thanks for your help!

1 Answer 1

11

It's about time this got a proper answer. Here's that explained as a step-by-step:

  1. Creating a Search API view. None of this will work unless, when you initially create the view, you choose one of the Search API options like "Show [Search Index]" and the appropriate index instead of "Show [Content]" in the drop down at the very start of the views creation process.
  2. Giving it a Context view display. A "Context view" is a type of View Display like a "View block" or a "View page" or an "Attachment view" etc. Create one with the "Add" button at the top of the View edit page.
  3. Load it as a Context in Panels or Page Manager. The thing that is special about Context views, is that systems built on cTools contexts (like Panels and Page Manager) can load the view early on in the process, and also, analyse it so they know what types of data to expect. In the Contexts page for your Page Manager page or Panel, add a context, choose Views, then find the right view.
  4. Place each part of the view as Content. Because cTools is loading the View as a context, and because cTools knows what Views are and how to make sense of them, it knows exactly what elements of the view it's going to get. If it was a views block, all it can do is just dump the whole output of the block somewhere, but since it's taking the time in the Context stage to analyse and make sense of the View, it can figure out that it's going to get seperate rows, headers, footers, exposed fitlers, etc. When you go to Content in the Panels / Page Manager interface, you'll find a 'Views Context' vertical tab with various bits of your view in it. This is the "bit more complexed" bit the guy refers to. If you want, you can go nuts and build a complex, sophisticated grid display placing the Views Row content type lots of times with different limits and offsets, with the first row highlighted, then a column showing rows 2-5, then a column showing rows 6-10... Or you can just stick the 'Views row' content in without limits or offsets (plus Views Header and Views Footer if you're using them) and it'll work as normal.
  5. Place the Facets, Current View block, etc. This is the important bit for the question. Because the View is loaded at the start of rendering the page, the search is loaded at the start of rendering the page, so order doesn't matter. If it was a Views block, it wouldn't be done until that block was rendered. So your facets and current search blocks can go anywhere.

All of this is a bit rough around the edges and might not work first time. If you're using Search API Spellcheck, don't forget to put it in the View Header then place the View Header in Panels / Page Manager. If your view gets its search terms using Contextual Filters instead of Exposed Filters, sometimes it just works, but you might sometimes need to set the argument manually and occassionally check and patch supplementary modules like Current Search Links and Search API Spellcheck depending on how the search is set up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.