Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
Is there a way to set the defaults for advanced search (or regular search)?
Avatar
dobbiedada
Member
Free Members
sp_UserOfflineSmall Offline
Feb 14, 2014 - 3:48 pm

Apologies in advance if there is already a topic about this, but is there a way to set the defaults for advanced search (or regular search)?  The default for the advanced search option seems to be 'current forum', 'match any word', and 'posts only'.  Is there a way to set the default to be 'current forum','match any word', and 'posts and topic titles'?  Generally I'm assuming that people would want to search both, so I'm hoping to set it as a default.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Feb 14, 2014 - 6:57 pm

depends.. many, but not all, have filters on them that allow you to customize the default... 

for scope, you can use filter 'sph_SearchFormForumScope'...

for matching, you can use filter 'sph_SearchFormMatch'...

do you know how to use wp filters?

Avatar
dobbiedada
Member
Free Members
sp_UserOfflineSmall Offline
Feb 14, 2014 - 7:47 pm

I haven't used them before but I will look into them - many thanks.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Feb 14, 2014 - 9:23 pm

oh,and also...  we did add a some args to the search form template function which may help...

see:  http://codex.simple-press.com/.....earchform/

you can set the searchIncludeDef argument for options...  have been meaning to add the scope and match stuff too, just not there now...  have opened a ticket...

for the wp hooks, see:  http://codex.wordpress.org/Plugin_API

its a bit harder than I let on too after looking a bit more...   you will have to use those filters and then search for the checked form element and uncheck it, then search for the other form element and check it...

unfortunately, I am heading out for a cruise and wont be able to work out the code for you until back.. Maybe Andy can help...

but I will also work to get that ticket included in the next release to make this easier...

 

 

Avatar
Yellow Swordfish
Glinton, England
SP Master
sp_UserOfflineSmall Offline
Feb 15, 2014 - 9:03 am

Let's do them one at a time:

Forum Scope:
The default IS 'current forum' as you have asked for. It is only NOT 'current forum' when the current view being displayed is not forum specific - i.e., Group View or members List etc. So that seems to satisfy this one.

Match:
This one is always set to 'Match Any Word'. Put simply it is hard to really use any other default value as the setting here really does depend on the search criteria. But 0 this is the default you eant so again - we are OK with this.

Forum Options:
This can be changed in the termplate. By default we set it to 'Posts Only' because (a) it is the most likely one people will use and (b) The 'Posts and Topic Titles' is more resource hungry and does result in slower performance because it has to do so much more work.

To change this - you need to make a small edit to the spHead.php template within the /templates folder of the Simple:Press theme you are using. At the top of that template you will see the block entitled 'Search FORM - OBJECT DEFINITION'. And at the very bottom of that block is the setting called 'searchIncludeDef' with the various settings that can be used. For 'Posts and Topic Ttitles simply change the 1 to a 3.

As always we recommend that you create your own SP theme so that any customisation is not lost during a future update. (http://codex.simple-press.com/.....g-a-theme/)

 

andy-signature.png
YELLOW
SWORDFISH
Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 620
Members: 17365
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10128
Posts: 79626