Manual talk:Hooks/SpecialSearchResults

From MediaWiki.org
Jump to navigation Jump to search

I have numerous pages with extensive embedded html. Much to my dismay, search result snippets include the raw html and html entities. I could not find a way to modify the search results to make them more palatable, so I did the unmentionable and hacked the core code : searchengine.php. In particular, I modified SearchResult->initText() as follows:

protected function initText(){
		if( !isset($this->mText) ){
			if($this->mRevision != null)
				$this->mText = html_entity_decode(strip_tags($this->mRevision->getText()), ENT_QUOTES, "UTF-8");

The strip_tags call removes all html tags. The html_entity_decode converts   to space (so long as you specify UTF-8). If there's a better way to achieve this end, please advise. --Gullion 20:44, 19 November 2009 (UTC)


manual says: "Referenced SearchResultSet can be easily wrapped for any purpose(caching results, etc). Please keep in mind that old behaviour used no reference for SearchResultSet objects."

I would appreciate an example of how SearchResultSet can be "easily wrapped." --Gullion 21:43, 19 November 2009 (UTC)