It would be great if a Search API page could be overriden by a Panels variant.
Page manager ships with a Panels variant that makes it possible to override Drupal Core search pages (search/node and search/user) with Panels variant. This makes it possible to take control over the page with Panels and place panes, blocks etc in a Panel layout.
As I understand it now the way to for example place Facets in the right sidebar on a Search API page is to place the Facet blocks in a region of your theme. Some sites don't use blocks but only uses Panels to do this.
If I find more information on this I'll add it as a comment if more people are looking for this funcitonality.
| Comment | File | Size | Author |
|---|---|---|---|
| #19 | 2315713-17--panels_integration--interdiff.txt | 3.56 KB | drunken monkey |
| #19 | 2315713-17--panels_integration.patch | 15.33 KB | drunken monkey |
| #15 | search_api_page-2315713-15.patch | 16.41 KB | kallehauge |
| #15 | search_api_page-2315713-15-interdiff.txt | 8.79 KB | kallehauge |
| #14 | search_api_page-n2315713-14.patch | 16.61 KB | damienmckenna |
Comments
Comment #1
pontus_nilssonI created a sandbox project that holds the functionality I was looking for at https://www.drupal.org/sandbox/pontusnilsson/2315831
Maybe the common way to do the same thing is to use Search API Views and make content pane display in Views and combine Search API and Panels that way. In my example Search API Pages was already implemented.
Comment #2
jpoesen commentedJust pointing out that pontus_nilsson's search_api_page_panels works out of the box and does exactly what he describes.
It would be *great* to see this shipped as a submodule of search_api_page.
Thanks.
J.
Comment #3
drunken monkeyThanks for posting this! Sounds like something that could be useful, so it's great you're publishing your code.
Adding it as a submodule to this module would be an idea, yes. However, as I don't know much about Panels and therefore don't really understand the code, I hesitate to do that. I don't want to be responsible for maintaining code I don't understand. (Probably, the submodule would be unnecessary anyways – it seems this would only slightly change our page callback and add a single hook and the plugins, so it could also be included in the module directly without adding significant complexity.)
So maybe Pontus should just make the sandbox a full project? Or if he would agree to keep maintaining the code, we could also add it to this module directly, if you say the code works well and think that this would make sense.
Comment #4
jpoesen commentedI figured a submodule would be best in order not to introduce an unnecessary dependency of search_api_pages on panels, but if there are ways to avoid that: great.
I totally get your point about not wanting to maintain panels code if that's not your thing. But I also feel that this addition would be a natural fit, *and* having it as yet-another-module feels kind of sad.
I'm not a deep panels expert but I'd be willing to help integrate and maintain this, if you and pontus_nilsson agree...
J.
Comment #5
pontus_nilssonI don't think the code needs to introduce a dependency to panels or ctools.
There is an implementation of hook_ctools_plugin_directory but that itself won't add a dependency to ctools.
To me it makes more sense to maintain this code in Search API pages since it introduces very small changes to the module but instead adds ctools plugins.
I'd be happy to convert my sandbox to a patch and we can work from there.
There is one change I would like to introduce to search_api_page_view so that the settings can for the page can be passed to the function instead of read from the page.
This is the proposed change:
Where $override_options = array() is introducted as a third argument and then the $override_options is merged in to $page->options. This way the settings for the Search API page can be changed in each instance it is rendered.
Comment #6
drunken monkeyYes, I already saw that in your sandbox, and that's totally fine. And also one large Pro for not making this a new module – copying the whole function code for just this change is a bit overkill, but otherwise of course necessary.
So, yes, would be great if you could make a patch for this! Thanks a lot!
And as you say, this of course won't introduce any dependency. It will just work if Panels is there, and be ignored otherwise.
Comment #7
damienmckennaLike this? I've not tested it yet though.
Comment #8
damienmckennaThis improved version fixes a typo on the search_api_page_ctools_plugin_directory() function, and adds a new search box pane.
Comment #9
damienmckennaFYI the patch (and sandbox) adds a pane / CTools content type for the search results from a given search page definition - I'm not sure of the intended use case but it doesn't solve the original request.
Comment #10
damienmckennaI moved the search box plugin into #2425179: CTools plugin for search box, so this patch no longer has that. That said, there are now two copies of search_api_page_ctools_plugin_directory(), so depending upon which one is committed first the other will need to be rerolled.
Comment #11
drunken monkeyThanks a lot for the initiative, Damien!
Could someone please test and verify this is correctly working?
Also, two little remarks:
I'm not completely sure, but I guess this isn't necessary anymore when it's directly included in this module?
If the keys contains slashes, wouldn't that then pass the part after the first slash as
$overridden_options? I guess we should here manually pass$type, $keys?Isn't it a bit unnecessarily "dangerous" to directly set the overridden options on the page object? If it is then saved somewhere later in the page request, the overridden options would be saved, too.
I can see that too many changes in other parts would be necessary to just use a new variable, but we should at least restore the original option values after the search (even though it's tricky, with the rendering only happening later).
The last one of those is fixed in the attached, along with some other minor problems. For the former, I'd first need confirmation whether I'm right there.
Fixing the comment standards in the patch required a bit of guesswork, though, as I have for the most part no idea what's going on, or what the correct phrasing is. It would be great if you, Damien, or something else who understands the code, could add appropriate
@paramand@returntags.And finally, could someone please test (and maybe review)?
Comment #12
damienmckennaI removed the two module_exists() calls because they shouldn't be necessary, wrapped some variable checks in !empty(), and removed the unnecessary "return NULL;" that was added.
Comment #13
drunken monkeyI'm of course aware that PHP will return
NULLby default, but I find it helpful to try and have uniform return points in a function/method: if a value is returned in some places, I prefer explicitly returningNULLin the others.Also, what about my second comment in #11? Wouldn't
$function($type, $keys)make more sense?Comment #14
damienmckennaUpdated to per #13.
Comment #15
kallehauge commentedThe "search_api_page_result" pane tried to call non-existing search_api_page_panels_view function and the entire Task plugin had wrong function names (copy paste errors from the sandbox I guess). - I have provided an interdiff and a new patch. But it's actually working fine for me, now :)
/ Kallehauge
Comment #16
pontus_nilssonJust gone through the new code and tested the patch in #15 from a vanilla installation and it works great. Happy to see this issue moving forward.
The only issue I noticed was when you disable a Search API page and have an enabled Search API page panels variant you get
Notice: Undefined index: search in search_api_page_search_api_page_menu_alter() (line 55 of /sites/all/modules/contrib/search_api_page/plugins/tasks/search_api_page.inc).If the Search API page is disabled there is no page callback.
Maybe a simple isset would be enough here?
Comment #17
drunken monkeyGood to hear it basically works, thanks for all the feedback and the work on the patch!
Here is an updated patch with a few style fixes and the suggested check for the menu item existence. Would have been great to also complete the doc blocks (e.g., docs for the
$typeparameter), but since I don't really know what that is/does, I couldn't really fix it. Not too bad, though, the patch would be RTBC for me.Could someone just check if it still works (with the latest HEAD – just committed #2425179: CTools plugin for search box which "interferes" a bit with this one)? Then I can finally commit it.
Comment #18
damienmckenna@drunken monkey: You forgot to add the patch ;-)
Comment #19
drunken monkeyAh, §$&#!
Sorry, and thanks for pointing it out!
Comment #20
martins.bertins commented#19 works well with 7.x-1.2
Thanks a lot!
Comment #22
drunken monkeyExcellent, great to hear. Thanks for testing!
Committed.
Thanks again to everyone who worked on this!
Comment #23
damienmckennaWoot! One less patch to add to all of my installs :)
Comment #24
blausch commentedI applied the patch, but now I have a problem.
Where can I add the search_api_page to my panel.
I could not find an object in the "whole panel thing".
Obviously, I understood something wrong.
I hint, where to find my search_api_page would be great.
Greetings
Berthold
Comment #25
damienmckenna@BLausch: Try downloading the current -dev release and clearing the caches, then it should appear.
Comment #26
blausch commented@DamienMcKenna
You are absolutely right. It works.
Thank You very much
Berthold Lausch
Comment #28
couloir007 commentedIs this patch still relevant?
Thanks!