Page MenuHomePhabricator

Provide way to override the behavior of default search box
Open, MediumPublicFeature

Description

I can't find any non-ugly way to alter the default search box suggestion functionality. I would like to change the namespaces and change rendering format a bit.

I checked how Wikidata does their thing, but even they override the whole search box with their own one.


Version: 1.24rc
Severity: enhancement
See Also:
https://bugzilla.wikimedia.org/show_bug.cgi?id=24214

Details

Reference
bz65753

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 3:22 AM
bzimport added a project: MediaWiki-Search.
bzimport set Reference to bz65753.
bzimport added a subscriber: Unknown Object (MLST).

(In reply to Niklas Laxström from comment #0)

I can't find any non-ugly way to alter the default search box suggestion
functionality. I would like to change the namespaces and change rendering
format a bit.

Which file were you looking at specifically?

If you're a skin, you can override the 'mediawiki.searchSuggest' module, which is normally loaded, by overriding the Skin::getDefaultModules() method.

If you're a ResourceLoader module, you can just depend on 'jquery.suggestions' *and* 'mediawiki.searchSuggest', and then call .suggestions() to override the rendering and selecting behavior (as well as a couple other things, see jquery.suggestions documentation) using code like below (every object key is optional in this call, and missing ones will keep their previous behavior). 'mediawiki.searchSuggest' actually does just that itself, calling .suggestions() several times.

$( '#searchInput' ).suggestions( {
result: {

		render: ...,
		select: ...

},
special: {

		render: ...,
		select: ...

}
} );

Hmm okay. I will try the RL approach by duplicating searchboxesSelectors and overriding 'fetch' and 'result' by calling .suggestions() in $( document ).ready(). If that works this can be closed as WFM.

I had to duplicate 'computeResultRenderCache' which is less than ideal.

Aklapper changed the subtype of this task from "Task" to "Feature Request".Feb 4 2022, 12:23 PM