Even though the homepage doesn't reveal any results, I'd like users to start from the homepage to start facet searching by clicking on the facet blocks that will direct them to the actual facet searching.
Even though the homepage doesn't reveal any results, I'd like users to start from the homepage to start facet searching by clicking on the facet blocks that will direct them to the actual facet searching.
Comments
Comment #1
cpliakas commentedBeaPower,
Thanks for posting. I'm not sure this has been entirely flushed out yet. Currently Facet API is not designed to be able to do this since it would require a generic API to execute "empty" queries, however it could be done if the backend allowed it to. For example, Apache Solr Search Integration does set the faceting information on the search page if no search has been executed, so I am guessing that it could be extended to be able to "show facets on page x" or something like that. I need to investigate a bit further, but any other information people could give would be helpful.
Thanks for the post,
Chris
Comment #2
cpliakas commentedSo unfortunately this can't be done easily without modifying the code. Fortunately, I don't think it will take too much work to make this happen. The roadblock in Facet API has been posted at #1252644: Remove assumption that the facets will link back to the page they are on. The corresponding feature request against Apache Solr has been posted at #1252648: Allow for enabling facet blocks on non-search pages. I am leaving this open as a support request and will post back how to configure facets on non-search pages once the functionality is complete.
Comment #3
cmjns commentedJust browsing issues and came upon this one. Noticed it because I just dealt with it myself. After reading through the code I noticed that the facet base path is set from $_GET['q']. Please forget I said this, but what I did was to write a snippet that saves the value of $_GET['q'] into a temporary variable. Then I set it to the intended base path for the facets, then immediately after executing an Apache Solr empty search put the value back. Crossing my fingers, but it seems to be working for the time being. Looking forward to a real fix for this!
Comment #4
BeaPower commentedCan I be able to get the snippet? Where did you add it, as I am a beginner, thanks.
Comment #5
cpliakas commentedSince you are a self-proclaimed beginner, I would stay away from this method as it required knowledge of the underlying Drupal system to get working. It has the potential of breaking a lot of other things, so I would hold back until there is a real fix. I also don't want to hijack this thread with supporting a temporary fix, even though it is a pretty cool technique.
Comment #6
BeaPower commentedWaiting for a release on how to show facets anywhere.
Comment #7
cpliakas commentedThe patches at http://drupal.org/node/1252644#comment-4919158 and http://drupal.org/node/1252648#comment-4919102 for Facet API and Apache Solr Search Integration respectively are ready for testing. They seem to work in my environment, and they add a setting to configure which paths the facets are displayed on.
Comment #8
cpliakas commentedNote: If you are testing, please post your results to the issues containing the patches and NOT this one.
Comment #9
dasjoi can at least confirm that this works with search api - facet api. create a "facets block" view display and set the "Search page path" accordingly
Comment #10
cpliakas commentedChanging title.
Comment #11
cpliakas commentedMarking as "fixed", since the question has been answered as to how this can be done. Follow the issue against Apache Solr Search Integration at #1252648: Allow for enabling facet blocks on non-search pages for patches and code examples on how to implement the solution. As of the RC1 release, Facet API is architecturally ready to support this without any modifications to the core code.
Comment #12
pnigro commentedHello,
Please forgive me for reopening this, but is this feature possible using a database backend (search_api_db) along with Views. I can create a new issue if necessary.
Thanks,
Paul
Comment #13
cpliakas commentedHi Paul.
Thanks for posting. I would actually recommend posting an issue against Search API since it is the module that would provide this functionality.
Thanks,
Chris
Comment #14
Drupal7N00bie commentedI'm a self-proclaimed beginner and it's initimating to ask you a question, but here goes. I'm trying to create something similar to the previous inquiries on this post with facets appearing before a search takes place like on http://drupaljobs.epiqo.com/. I am using Facet API 7.x-1.2 and I am trying to apply the two patches (http://drupal.org/node/1252644#comment-4919158 and http://drupal.org/node/1252648#comment-4919102), but running into an issue from the shell. Here's the messages I received (I've only tried the Facet API patch so far):
lamp:/var/www/drupal/sites/all/modules/facetapi$ ls
contrib facetapi.admin.inc facetapi.block.inc facetapi.date.inc facetapi.install
facetapi.module.orig facetapi.theme.inc plugins
facetapi-1252644-2.patch facetapi.admin.js facetapi.callbacks.inc facetapi.facetapi.inc facetapi.js
facetapi.module.rej facetapi.tokens.inc tests
facetapi.admin.css facetapi.api.php facetapi.css facetapi.info facetapi.module
facetapi.requirements.inc LICENSE.txt
lamp:/var/www/drupal/sites/all/modules/facetapi$ patch < facetapi-1252644-2.patch
patching file facetapi.module
Hunk #1 FAILED at 429.
1 out of 1 hunk FAILED -- saving rejects to file facetapi.module.rej
can't find file to patch at input line 67
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/plugins/facetapi/adapter.inc b/plugins/facetapi/adapter.inc
|index 3241e40..88cc955 100644
|--- a/plugins/facetapi/adapter.inc
|+++ b/plugins/facetapi/adapter.inc
--------------------------
File to patch:
I haven't tried Git yet, but shouldn't it work from the shell? Content from my .rej file is below:
--- facetapi.module
+++ facetapi.module
@@ -429,30 +429,36 @@
* count setting.
*/
function facetapi_get_searcher_info() {
- $searcher_info = module_invoke_all('facetapi_searcher_info');
- foreach ($searcher_info as $searcher => $info) {
- // @see http://drupal.org/node/1167974
- // Converts "type" to an array and stores in "types".
- if (isset($info['type']) && !isset($info['types'])) {
- $info['types'] = array($info['type']);
- }
+ $searcher_info = array();
+ foreach (module_implements('facetapi_searcher_info') as $module) {
+ // Iterates over the module's searcher definition.
+ foreach ((array) module_invoke($module, 'facetapi_searcher_info') as $searcher => $info) {
+ // @see http://drupal.org/node/1167974
+ // Converts "type" to an array and stores in "types".
+ if (isset($info['type']) && !isset($info['types'])) {
+ $info['types'] = array($info['type']);
+ }
- $info += array(
- 'name' => $searcher,
- 'path' => '',
- 'types' => array('node'),
- 'url_processor' => 'standard',
- 'supports facet missing' => FALSE,
- 'supports facet mincount' => FALSE,
- );
+ $info += array(
+ 'module' => $module,
+ 'name' => $searcher,
+ 'path' => '',
+ 'types' => array('node'),
+ 'url_processor' => 'standard',
+ 'supports facet missing' => FALSE,
+ 'supports facet mincount' => FALSE,
+ );
- // @see http://drupal.org/node/1167974
- // Makes sure old style "type" is present.
- if (!isset($info['type'])) {
- $info['type'] = $info['types'][key($info['types'])];
- }
+ // @see http://drupal.org/node/1167974
+ // Makes sure old style "type" is present.
+ if (!isset($info['type'])) {
+ $info['type'] = $info['types'][key($info['types'])];
+ }
- $searcher_info[$searcher] = $info;
+ // Maps "types" so we can do faster lookups via isset().
+ $info['types'] = drupal_map_assoc($info['types']);
+ $searcher_info[$searcher] = $info;
Thank you!
Comment #15
dasjothis should go into a separate support request
Comment #16
cpliakas commentedHi Drupal7N00bie.
Welcome to Drupal! There is no need to be intimidated, and I look forward to your future posts and (hopefully) contributions as you get more familiar with the software and platform.
So the issue that you are experiencing is that the patches were actually committed to the module a while ago. So not only were the patches rolled against a much older version of the codebase, but they also are already integrated into the codebase you are patching against. Therefore it is expected that git is not allowing the patch.
Just for future reference, if the issue "Status" is "Closed (fixed)', look for a comment similar to #1252644-12: Remove assumption that the facets will link back to the page they are on that will point to the actual commit so you can see if it is in the version of the module you are using. If the commit happened before the release date of the version on the module page, chances are it's in there. Also, as a maintainer I tend not to see comments posted to closed issues, so I was lucky to happen up this one since the issue volume is pretty low right now. So in the future, feel free to post a new issue referencing the closed ones.
Regarding the request, the modules that implement Facet API (i.e. Apache Solr Search Integration, Search API, etc) are responsible for providing this type of functionality. For example, the Apache Solr Search Integration module has a text field that allows you to specify paths on non-search pages that facets should display on. I have no idea how Search API does it, though. The good news is that http://drupaljobs.epiqo.com/ is built using the Recruiter distribution, so you can actually download and install the distro locally to see how it is accomplished. You can also search the Search API issue queue and post a support request if one doesn't already exist.
Hope this helps, and welcome.
Chris
Comment #17
Drupal7N00bie commentedThank you so much for taking the time to explain the protocol and for providing me with a good starting point that I can work from. It's really helpful!
Thanks for the welcome too :)
Comment #18
Frederic wbase commentedHere is my work arround for this problem, no coding required!
now you have also the other facet blocks everwhere because the search is activated, if you want you can hide the created block with css.
grts
frederic wbase