Hi,

I am trying to build a very extensive site in a few days (started yesterday, finishing wednesday). It is going to grow like crazy and the thing is, i would like to use "guided search" for taxonomy terms, BUT the problem is that this is likely to grow very quickly. What happens when there are 100+ taxonomy terms? It would be a long page. I think I am going to hack the code to create a pulldown for the taxonomy terms; which will have an onchange behaviour going to the corresponding results page... I guess this is not much of a support request, but i thought that maybe the idea could be usefull for a future version.

cheers

PS if the taxonomy terms are limited I would like to know.

Comments

dagomar’s picture

Ok really sorry.

This is no good, I will probably omit the feature from the site for now and use views pages and blocks for some similar but simpler solution. When i get some free time I will see how I can be helpfull for this promising module.

dagomar’s picture

Lol

still playing around with this module I found out that i can limit the amount of categories displayed... DOH!!
But i still feel that a pulldown could be very handy (page would be much smaller) Also I think I would like to change the sorting to amount of nodes per category (as described in http://drupal.org/node/170463). Tomorrow I will cheap hack these 2 features (to at least see how it looks)

David Lesieur’s picture

Glad you found the option for the number of categories. :-) However, a pager still needs to be implemented in the 'more' page of individual facets, because thousands of categories could become a problem. A few hundreds should be fine though.

dagomar’s picture

Thanks for the reply david,

You are right, if thousands of categories exist we still need the "more..." option. But then that link could also be displayed in a jumplink-pulldown. I am looking for it now, but if u happen to know where that is being build exactly, gimme a peep ok ;)

dagomar’s picture

ooooouch!

that took me the whole morning, but in the end i have succeeded. Instead of having a list of categories, it now display a select form element. Sweet! It took me so much hacking the code that i am scared to post how i did it. But it definately looks a lot better then how it was. So i hope this could be standard in a future version!

Cheers, Dago

David Lesieur’s picture

Is there a link you can share for us to try your UI? That would be great.

dagomar’s picture

i will post that as soon as possible (probably tomorrow)

dagomar’s picture

I don't post the link now, because it is only a test server for now. It seems I cannot alter the comments i make here, otherwise i would post it. I have send a link to you david. We will probably go live this week or early next week, so then i will post the official url.

David Lesieur’s picture

Sure, no rush. Post only when you're ready and if it's no trouble. :-)

David Lesieur’s picture

Title: More options for taxonomy? » Use dropdown lists for categories in Guided search
Category: support » feature
ju.ri’s picture

Did someone get this to work? I think it would be a great option. On my site I have several vocabularies with more than 20 terms, they just don't fit in the sidebar. Also, a dropdown-box actually shows you more terms than a list, because everythig behind a "more" link is kind of lost IMO.
At the moment I use exposed filters with views_filterblock module to get it in the sidebar. I would love to switch to wonderful faceted search if this is possible!

kulvik’s picture

I'm also very interested in this. Any code snippens / patches out there?

Best regards,
Thomas Kulvik

Ny Media AS
www.nymedia.no
+47 4000 7955

asak’s picture

subscribing.

this will be cool.

dagomar’s picture

This IS a long time ago. As you can read in my first post, I had to do a full site in a matter of days, with being so busy I never got around posting my solution here. However! What I did was so extremely rough hacking of the module, that it is just unusable as a patch. Also, I created this for the faceted search version 5.x-0.4. I cannot say what will happen if you try to make these changes in a newer version of FS, let alone version 6.x. I am willing to show how I did it though, perhaps it is still useful for someone out there.

Also, I may be interested in making a patch or little module for cash, for 6.x-1.x-dev. I imagine I would put an extra option for facets in the "environment" page.

A working version of the 5.x.0.4 module can be seen on the right side of http://www.getcars.nl

Here's how I did it, I will tell line numbers, and what I changed. I am not sure if all these changes are necessary, but I am not checking it now because I am very busy... All changes take place in 'faceted_search_ui.module'

Line 379, Commented out (reason unknown)
// $labels[] = check_plain($facet->get_active_category()->get_label());
line 453-455, Commented out (reason unknown)

 // $ui_state['stage'] = 'select';
// $path = faceted_search_ui_build_path($ui_state, $search->get_text());
// $form['go-select']['#value'] = '<div>'. l(t('Advanced search'), $path) .'</div>';

line 710, changed theme function parameter to a new function, possibly i made a new function to keep original code intact.
$items[] = theme('faceted_search_ui_category2', $category, $path);
line 841, here starts the true mess. I commented something out, and changed the output to a themeable dropdown

 //return theme('item_list', $categories);
	  $output = drupal_get_form('my_faceted_search_dropdown_form', $form, $facet, $categories);
return $output;

line 847, commented out something (reason unknown)
// return '<strong>'. check_plain($facet->get_label()) .'</strong>';
line 854, here's that new function

function theme_faceted_search_ui_category2($category, $path) {
$category->get_count() .')</span>';
  $mypath[0] = $path;
  $mypath[1] = $category->get_label() . ' ('. $category->get_count() .')';
  return $mypath;
}

line 1037, here is that form, finally.

function my_faceted_search_dropdown_form($form, $facet, $categories) {
    $vid=1;
    $formname= $facet->get_label();
    $options[] = t('List by ' . $formname);
	foreach ($categories as $category) {
	$options[url($category[0])] = $category[1];
	}
    //Build dropdown select
    //If we try to build OnChange directly it gets mangled, so put in array to confuse the forms api
    $form['category'] = array(
      '#type' => 'select',
      '#name' => $formname,
      '#id' => $formname,
      '#title' => '',
      '#default_value' => '',
      '#options' => $options,
      '#description' => '',
      '#multiple' => $multiple = FALSE,
      '#required' => $required = FALSE,
      '#attributes' => array('onChange' => "top.location.href=document.getElementById('$formname').options[document.getElementById('$formname').selectedIndex].value"),
    );
        return $form;
}

Sorry for the complex guide. I just realised this this was my first drupal site ever, and I would do thing much differently now. Probably a little module to change the output of the module would suffice.

seancorrales’s picture

For users out there wanting to modify this in Drupal 6...

There is a themable function in "faceted_search_ui.module" called "theme_faceted_search_ui_categories". This controls the output of the categories. At least, it does for guided search.

It should be somewhere around line #1324.

Most of the functions that control the output of the UI can be overridden in your template.php file. When I have a custom function returning select boxes, I'll be sure to post it back here for others to use.

nicopacino’s picture

I use Drupal and faceted search and i'm also very interested in this.

I tried to modify the function called "theme_faceted_search_ui_categories" to output a drop down list (Drupal 6) but i didn't succeed.

Is someone have the solution for Drupal 6 ?

Thank's

David Lesieur’s picture

I am not convinced that implementing this with forms is the ideal way. Forms either require the user to submit the form (which is something Faceted Search tries to avoid), or need JavaScript for the submission to become automatic upon selection. So if we need JavaScript anyways, then why not go with a solution based on JavaScript only? Hovering or clicking a facet could pop a list of clickable terms. The system would degrade gracefully to plain lists of terms when JavaScript is not present (which would be nicer than falling back on a form with submit buttons). Opinions about this?

kardave’s picture

dagomar's one-click drop-down solution looks nice on http://www.getcars.nl

I have hundreds of terms too...

gutomec’s picture

How can i do it (http://www.getcars.nl) in Faceted Search for Drupal 6?

momper’s picture

subscribe

weseze’s picture

I've written a small module to override the generated html. Perhaps you can use and customize it. http://drupal.org/node/555782#comment-1975408

momper’s picture

@wesley

do you think this can also help for http://drupal.org/node/560120

thanks momper

weseze’s picture

it might, but I've got a feeling there is a better (easier) way of doing that... some sort of taxonomy listing module perhaps?

smd_ksu’s picture

Ok, here is what I did to make this kind of work. First use @wesley_2mpact's great module from above to turn them into unordered lists. Then I used one of the many jQuery tutorials out there to turn the lists into drop-down menus. Works great.

DrupalSza’s picture

H all...
Found this thread while looking for the same solution.
I installed @wesley_2mpact's module to change the tables into lists. . .

now what? I can't seem to bring this home. I viewed a couple jquery tutorials but seem to be out of my league...

DrupalSza’s picture

perhaps should have commented on this thread:
http://drupal.org/node/555782#comment-1975408

Cyberwolf’s picture

Subscribing.

fpr’s picture

This little hack is working fine in Drupal 6 (added to template.php):

function phptemplate_faceted_search_ui_categories($facet, $categories, $stage) {
if (is_array($categories) && !empty($categories)) {
$html = '<br /><select onchange = "if(this.selectedIndex>0) top.location.href= this.options[this.selectedIndex].value"><option>Select</option>';
foreach ($categories as $html_for_term) {
 
$html_for_term = preg_replace("/<span class=\"faceted-search-category\"><a href=\"/", "<option value=\"", $html_for_term);
$html_for_term = preg_replace("/<\/a><span class=\"faceted-search-count\">/", "", $html_for_term);
$html_for_term = preg_replace("/<\/span><\/span>/", "</option>", $html_for_term);          
$html .= $html_for_term;
}
}
$html .= '</select>';
return $html;
}
Summit’s picture

Subscribing, greetings, Martijn

Ela’s picture

Thank you fpr , #28 works well for showing dropdown list.
Is there any way that one can select from multiple dropdown options and then hit go before viewing results?
For example:
Choose: country
Choose: City
Choose: bedrooms
Hit "go" or "search" and view results?

Ddroid’s picture

Hi Ela,

Did you ever get this to work the way you wanted? Looking for the same solution. Thanks.

Ela’s picture

Hi Ddroid,
No, I did not find a solution yet :( If you find one, please let me know as well.

jjoseph’s picture

Thank you so much! This worked very well :) Actually used this not for drop down menus but to add a click-display function to the lists.

RaulMuroc’s picture

RaulMuroc’s picture

Title: Use dropdown lists for categories in Guided search » Use (custom) search box for categories in Guided search

Would be nice to have also the possibility to do a simple search box.

A search box where user introduces the word, for example, 'Barcelona' and it searches through City and Country location API fields (not location cck).

This would avoid have such a huge lists and also is another way of thinking for search improvement.

I'm working on it, hope soon can put a patch/code.

Help is welcome :)