I have installed the custom search module and the default $search_box is being replaced with the custom search box instead with the tick boxes necessary to search by specific content types. This is exactly what I need.

I have chosen to display the basic search form on the results page so that the user can search again if necessary (but no advanced search option). However, when I do a search, the form on the search results page is the Drupal default that has the label 'enter the keywords' above it and no options to search by content type again (this is on example.com/search and also example.com/search/node/keyword type:content_type).

How can I put the custom search box on /search and /search/node/keyword type:content_type)?

CommentFileSizeAuthor
#7 categories.png58.18 KBjdanthinne
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jojo86’s picture

*bump* anyone???

jdanthinne’s picture

Why don't you use advanced search? There you can have the content types selectors, and more…

jojo86’s picture

The advanced search box has too many options on it. After looking closer into the custom search settings, I can see that I can turn off the OR, And and Negative boxes, as well as reducing the content types. Thanks for suggesting that :)

However, how can I remove the category box and also how can i make the advanced search box show as expanded rather than closed (on the page, you have to click Advanced Search to see the options)?

jojo86’s picture

Actually, I have used CSS to remove the category selection box:

.search-advanced .fieldset-wrapper #edit-category-wrapper {
display:none
}

However, I still have the issue of it being collapsed on load and that the search box is displaying the types - I only want it to display their search terms, not the types. I'm going to take a look at the js that controls the advanced search collapsed and expanded states to see if I can add it to my own js files but with my own function.

jojo86’s picture

I have figured it out!

To deal with the expand/collapse issue, I used:

function mytheme_theme() {
    return array(
        'search_form' => array(
          'arguments' => array('form' => NULL)
        ),
    );
}

function mytheme_search_form($form) {
    $form['advanced']['#collapsible'] = FALSE;
    $form['advanced']['#collapsed'] = FALSE;

    return drupal_render($form);
}

To deal with the content types in the search box issue, I used this in search-results.tpl.php:

<script type="text/javascript">
    function hidefilters(field_id) {
      val = document.getElementById(field_id).value;
      newval = val.replace(/( [a-zA-Z]*:[a-zA-Z0-9_-]*).*/, '');
      document.getElementById(field_id).value = newval;
    }
    hidefilters('edit-keys');
</script>
(reference http://drupal.org/node/141788)
jdanthinne’s picture

Status: Active » Needs work

I'll try to add options in the admin as soon as have some time to do it, so it will be available for everyone, and in a better way (without javascript) ;-)

jdanthinne’s picture

Status: Needs work » Active
FileSize
58.18 KB

Hi, I've just committed changes to the DEV version.
There are now options for a collapsible/collpased advanced search form.

I've also checked for the category selector that should be hidden, and it's working fine. When I uncheck all vocabularies, the category is removed (see screenshot).

BUT as soon as I enable the "Taxonomy translation" module, it seems that the category comes back! I think this is a bug in this other module, not mine, because the category selected displays blank lines where it should display the vocabulary name. I'll have a look at that!
Are you using "Taxonomy translation"?

jdanthinne’s picture

I confirm that a bug in Taxonomy Translation is causing the malfunction of my module...
See #1010504: in advanced search only one vocabulary shows terms to search on. I'll try to help to find the bug.

jdanthinne’s picture

Status: Active » Needs review

Ok, try my fix here http://drupal.org/node/1010504#comment-4124140 , and then, the unselected vocabularies in the Results page settings will disappear from the advanced search, as it used to without Taxonomy Translation.

heddn’s picture

Status: Needs review » Fixed

I'm taking some liberty but a bug report for D6 from 2010 is probably fixed. If you disagree, please reopen and provide more details.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.