Search result excerpts

Permalink
Is there a way to show search result excerpts (some text around the search keyword) in my search results, instead of just the page title? This would be a really cool feature and helps the user get a better sense of whether a search result is relevant or not.

Example: I search for "amet", and the result shows:
[...] ipsum dolor sit *amet*, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat [...]

This, using the PageList() API.

Is it already possible somehow? Or would it potentially be a nice new feature for concrete5?

Note that I don't want to iterate through the blocks and find the text containing the keyword, as that would perform badly.

For performance reasons the excerpt should be already contained in the search index.

entreprenr
 
drbiskit replied on at Permalink Best Answer Reply 1 Attachment
drbiskit
Hi - This should already be happening. In the default search results, it would usually show the page title, then an excerpt of text with your search term highlighted, and then the linked URL the page - See the attached screen grab for an example.

Is your search result list using a custom template perhaps.

Could you provide a URL to the site at all?
entreprenr replied on at Permalink Reply
entreprenr
Oh, my bad. I didn't look at the out-of-the-box concrete5 search block. I usually use PageList() directly and thought it returns just an array of Page objects.

There it is:
$r->getPageIndexContent()

Thanks for pointing that out :)
drbiskit replied on at Permalink Reply
drbiskit
No worries - all good!

=0)