Jump to:
| Project: | Faceted Search |
| Version: | 6.x-1.x-dev |
| Component: | Views integration |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Issue Summary
I really like this module and have been playing around with it quite a bit now. Trying to create a perfect search setup for my current project, I've also been using views_fastsearch and views_filterblock to create some other cool search functionality, and now I was wondering if there was a straight-forward way of combining the functionality of the two things?
I.e. creating a view with exposed filters and using that view as output for a particular facet search environment, and then being able to use the exposed filters (as a block) like any other elements of the faceted search.
I suppose this must be possible by writing a view_filter_facet.module, but not entirely sure how to go about this. If there is more general interest in such a feature (and not a more obvious solution around already), I'd be happy to sit down and write this module -- some help / pointers as to how to go about this would always be appreciated, though.
kmh
Comments
#1
I guess one way to implement this would be to theme the guided search block so that it consists of fieldsets for each of the facets.
I have just been looking at this today, it appears we are looking at overriding theme_faceted_search_ui_categories($facet, $categories, $stage) - Im totally in the dark about where to go forward from here, but ill keep plugging away....
#2
Ultimately, what is really needed is #256958: Guided search based on a view. But other than that ideal solution, perhaps Faceted Search's views integration could be strengthened to support exposed filters. However, I have not investigated this issue at all, so at the moment I have no idea what it entails.
#3
#4
Hi,
I was disappointed to see the exposed filters doesn't filter the output of faceted search. Later I found that the problem can be solved by modifying the attribute 'action' of the filters' form. Just copy the below code to your theme's template.php and then change VIEWNAME to the name of your view.
<?phpfunction phptemplate_views_display_filters_VIEWNAME($view) {
$form = drupal_retrieve_form('views_filters', $view);
$form['#action'] = request_uri();
drupal_process_form('views_filters', $form);
return drupal_render_form('views_filters', $form);
}
?>
Tim
#5
.
#6
You can get views exposed filters to work.
<?phpfunction YourCustomModuleName_form_alter(&$form, $form_state, $form_id){
if($form['#id'] == 'views-exposed-form-searchfview-default'){
$form['#action'] = request_uri();
}
}
?>
put the above snippet in any module (note that it should NOT go into template.php in your theme folder). Substitute
views-exposed-form-searchfview-defaultwith the id of your exposed filter and you will be able to run a run a views filter with faceted search. Checked with drupal 6.10 and faceted search with views integration.Also see http://drupal.org/node/236162
#7
Awsome if this works! Havn't tried it yet. Exactly where can i put this snippet? my themes template?
#8
This snippet should be placed in a custom module that you can create -- that will take hardly 5 mins to create. It should not go in phptemplate. The snippet will not work there.
#9
It would not be too hard to implement a generic equivalent to this snippet in faceted_search_views.module...
The only thing I'd worry about is altering the form even when the view is used outside of Faceted Search. This is probably something we'd want to prevent, perhaps by checking the current path?
#10
Here's a hint on how to support exposed filters properly in an embedded view.
The Signup module has used this to solve a similar issue.
#11
exactly how should my module look? I have no experience on making custom modules and i really need my exposed filter view to work with faceted search.
I have an exposed taxonomy filter (id: tid)
any help much appreciated.
#12
Where do you place the code in these hints? (i.e. $view->override_path = 'some path')
#13
subscribing
#14
OK I got it working using the method described in #6 I did have to make a couple of other changes by hooking in template.php
theme_faceted_search_ui_remover_link_current_search() and
theme_faceted_search_ui_category()
function carnal_faceted_search_ui_remover_link_current_search($path) {// TODO: nice default icon instead of 'x'
$options = array(
'html' => TRUE,
'attributes' => array('title' => t('Remove this term')),
);
if (!empty($_GET['date_filter'])) {
$options['query'] = array('date_filter[value][date]' => $_GET['date_filter']['value']['date']);
}
return l('[×]', $path , $options);
}
and a similar fix in the other one (not so clean because it also includes some code to handle realnames)
function carnal_faceted_search_ui_category($category, $path) {
// Note: get_label() is responsible for filtering its returned string.
if ($path) {
$options = array('html' => TRUE);
if (!empty($_GET['date_filter'])) {
$options['query'] = array('date_filter[value][date]' => $_GET['date_filter']['value']['date']);
}
if ($category->_uid) { // author_facet
$user = user_load(array('uid' => $category->_uid));
$target->_name = strip_tags(theme('username',$user));
$label = l(strip_tags(theme('username',$user)), $path, $options);
} else {
$label = l($category->get_label(TRUE), $path, $options);
}
}
else {
$label = $category->get_label(TRUE);
}
// Note: Tooltips rely on class 'faceted-search-category'.
return '<span class="faceted-search-category">'. $label .'<span class="faceted-search-count"> ('. $category->get_count() .')</span></span>';
}
Basically I had to carry the argument from the exposed view over to the link created so that it wasn't lost every time you clicked a new facet or removed an old one.
See http://sf.carnalnation.com/events/results for the working system (it's also been patched to allow multi selects from the same vocabulary but that's another issue entirely).
#15
jpp, this is very specific to your environment i guess, with user facets and date filter.
Is it possible to translate this code to a more generic version?
#16
Sorry, Yes it's specific however I don't have time to do a generic patch, however I wanted to give the pointer so that anybody implementing this has an idea of where to go.
A more generic version would find all the views variables in use and make sure they get carried over into the urls to add/remove facets. It's probably a couple of hours of work but it's a couple of hours I don't have right now.
#17
I understand completely. However, the ability to filter (exposed) faceted search results with the help of your embedded view would be a great feature. Is this possible with only a custom module or do we need to complement the theme?
#18
How do I implement this? I am lost.
Where do we put the code snippet? Can't we integrate this into Faceted-Search module?
#19
Hi Everyone,
As far as I can tell, sidharth_k got this working properly, but i'm not real sure how to implement it. I have dropped the snippet posted onto a module I am using in the site. It is actually a very very basic module I put together after reading a number of other posts to solve an unrelated issue.
As I understand it, it can go on any module - so this is not an issue.
The problem I am having is that Im not real sure if it is set up correctly.
I have a view set up that runs a proximity search using the Location module. A user inputs a post code and a radius, and this brings up a list of options within that search.
At the same time, I have a guided search block sitting on the same page. The idea here is that you would get a series of items that are within a given radius from your post code, then you would use the guided search block to drill down what you are looking for.
That is what I thought this snippet would allow me to do, however it seems that by clicking any of the guided search links, I am taken away from the proximity search.
Is there a better way to do this? Or am I simply misunderstanding/misusing sidharth_k's solution? Or should this be working just fine - and I hooked something up wrong?
Thanks for your help.
#20
By adding the code in #6 i have been able to obtain the results i wanted, however I still get this error:
recoverable fatal error: Object of class faceted_search could not be converted to string in view.inc on line 1165
showing up on every page from adding an exposed filter to a faceted search result view. Everything works as it should so just taking out the messages section of page.tpl would work, but i hate to do that. Anybody have any suggestions?
#21
I made the module as #6 but I get redirected to example.com/?someviewsparameter instead of incorperating the faceted search...
#22
Ok fixed it, got it working with proximity filter.
Made the module as in #6.
Only messed up with the id, used the view id instead of the HTML id.
So for others, it's the id that defines your filter div, something like "views-exposed-form-filtername-default"
#23
Loving Faceted Search and excited to try out the fix at #6.
Are there any plans to commit this functionality? The READ ME says 'With the Faceted Search Views module, you may use the Views module to display and further filter search results' but, without the ability to expose those filters, this is a little limited.
Cheers
J
#24
subscribing - would anyone be able to kindly create a patch that can be reviewed?