This project is not covered by Drupal’s security advisory policy.

Extend

This module aims to extend Search API with a new processor plugin that adds a link with a "scroll to text" fragment to the highlighted search term within the result excerpt, allowing users to click the link and automatically scroll to the first instance of the highlighted search term on the page.

This leverages the newly supported Text Fragments browser feature.

Text Fragments let you specify a text snippet in the URL fragment. When navigating to a URL with such a text fragment, the browser can emphasize and/or bring it to the user's attention.

REFERENCE:

Features

The module aims to improve user experience by allowing users to click on the highlighted search term within the search results excerpt, which then takes them to the page, and then highlights and scrolls to the first instance of that search term in the context of the previous search action.

For example, without this module, if I specify "Drupal" as my search term and submit the search form, I may see "Drupal" highlighted within the search results excerpt, but only the search result title is clickable, which takes me to the node's page. I then would need to search within that page for the appearance of "Drupal".

However with this module enabled, and the Text Fragment processor enabled within Search API's config, the search results excerpt will apply a link to the highlighted term, which links to the node page along with the text fragment within the URL so that when the page loads it will highlight and scroll to the first instance of that search term on the page. This is especially helpful for pages containing lots of content, where the text fragment may save the user considerable time from having to find the contextual search term on the resulting page.

Post-Installation

After installing the module, make sure to go to Search API's configuration page for your specific index, and make sure you enable the "Highlight with Text Fragment" processor and save e.g., /admin/config/search/search-api/index/search/processors

Config Processor Step 1

Within the processor settings tab you have the option to highlight partial matches and create excerpt, as well as specifying the highlighting prefix and suffix.

Config Processor Step 2

Additional Requirements

This module requires the Search API module.

Project information

Releases