This question about Missing functionality: Answered

How can I make the AdvancedSearchForm respect my Site Preferences?

Default search type for my site is keyword search. But WebSearch always uses 'word' search by default, no matter what search preferences are. How can I make WebSearch respect site preferences?

Unfortunately there is no simple override for the default search type. You could modify the System.WebSearch topic, but you would lose your changes when upgrading to a new version. The better solution is to create your own version of WebSearch - for example, SiteSearch.
  • Copy System.WebSearch to System.SiteSearch and modify the defaults
  • Copy System.WebSearchAdvanced to System.SiteSearchAdvanced and modify it to include System.SiteSearch
  • Then in each web where you want to use the modified search
    • Edit WebSearch to %INCLUDE System.SiteSearch
    • Edit WebSearchAdvanced to %INCLUDE System.SiteSearchAdvanced
  • In order to make this the default for any new webs you create, you can also edit these topics in the _default template web.
Changes to make to the SiteSearch copy of System.WebSearch

In the following block, change the default word to keyword
%STARTSECTION{"searchparamsadvanced"}%%INCLUDE{"%TOPIC%" section="searchparamssimple"}%;type=%URLPARAM{"type" encode="url" default="keyword"}%;nosearch=%URLPARAM{"nosearch" encode="url"}%;limit=%URLPARAM{"limit" encode="url"}%;excludetopic=%URLPARAM{"excludetopic" encode="url"}%;casesensitive=%URLPARAM{"casesensitive" encode="url"}%%ENDSECTION{"searchparamsadvanced"}%

And down further in the optionsadvanced section, change the defaults of the two radio buttons. Remove the default="word" from the word button, and add default="keyword" to the keyword button. Note that you need to quote the "type" in the %URLPARAM macro.

<input type="radio" class="foswikiRadioButton" id="word" name="type" value="word" %IF{" '%URLPARAM{"type"}%' = 'word' " then="checked=\"checked\"" else=""}% /><label for="topic"> %MAKETEXT{"Word search"}%</label><br />
<input type="radio" class="foswikiRadioButton" id="keyword" name="type" value="keyword" %IF{" '%URLPARAM{"type" default="keyword"}%' = 'keyword' " then="checked=\"checked\"" else=""}% /><label for="topic"> %MAKETEXT{"Keyword search"}%</label><br />

I don't know if there is any easier way to accomplish this. None that I can see anyway.

-- GeorgeClark - 19 Apr 2011

Task Tasks.Item10658 opened. We are investigating fixing this and restoring the SEARCHDEFAULTTTYPE setting.

-- GeorgeClark - 20 Apr 2011

QuestionForm edit

Subject Missing functionality
Version Foswiki 1.1.2
Status Answered
Topic revision: r4 - 20 Apr 2011, GeorgeClark - This page was cached on 06 Aug 2020 - 21:42.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy