Manual:Hooks/ShowSearchHit

From Linux Web Expert

ShowSearchHit
<translate> Available from <tvar name=1><translate> version <tvar (Gerrit change 32040)</tvar></translate>
Customize display of search hit.
<translate> Define function:</translate>
public static function onShowSearchHit( $searchPage, $result, $terms, &$link, 
&$redirect, &$section, &$extract, &$score, &$size, &$date, &$related, &$html ) { ... }
<translate> Attach hook:</translate> <translate> In <tvar name=1>extension.json</tvar>:</translate>
{
	"Hooks": {
		"ShowSearchHit": "MediaWiki\\Extension\\MyExtension\\Hooks::onShowSearchHit"
	}
}
<translate> Called from:</translate> <translate> File(s):</translate> search/searchwidgets/FullSearchResultWidget.php
<translate> Interface:</translate> ShowSearchHitHook.php

<translate> For more information about attaching hooks, see <tvar name=1>Manual:Hooks </tvar>.</translate>
<translate> For examples of extensions using this hook, see <tvar name=cat>Category:ShowSearchHit extensions</tvar>.</translate>

Details

  • $searchPage - The SpecialSearch instance.
  • $result - The SearchResult to show
  • $terms - Search terms, for highlighting
  • &$link - HTML of link to the matching page. May be modified.
  • &$redirect - HTML of redirect info. May be modified.
  • &$section - HTML of matching section. May be modified.
  • &$extract - HTML of content extract. May be modified.
  • &$score - HTML of score. May be modified.
  • &$size - HTML of page size. May be modified.
  • &$date - HTML of page modification date. May be modified.
  • &$related - HTML of additional info for the matching page. May be modified.
  • &$html - May be set to the full HTML that should be used to represent the search hit. Must include the ‎<li>...‎</li> tags. Will only be used if the hook function returned false.