Skip to content
Merged
1 change: 1 addition & 0 deletions administrator/components/com_finder/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@
name="highlight_terms"
type="radio"
label="COM_FINDER_CONFIG_HILIGHT_CONTENT_SEARCH_TERMS_LABEL"
description="COM_FINDER_CONFIG_HIGHLIGHT_CONTENT_SEARCH_TERMS_DESC"
layout="joomla.form.field.radio.switcher"
default="1"
>
Expand Down
1 change: 1 addition & 0 deletions administrator/language/en-GB/com_finder.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ COM_FINDER_CONFIG_FIELD_OPENSEARCH_NAME_LABEL="OpenSearch Name"
COM_FINDER_CONFIG_FILTER_COMMONWORDS_LABEL="Filter Common Words"
COM_FINDER_CONFIG_FILTER_NUMERICS_LABEL="Filter Numeric Terms"
COM_FINDER_CONFIG_GATHER_SEARCH_STATISTICS_LABEL="Gather Search Statistics"
COM_FINDER_CONFIG_HIGHLIGHT_CONTENT_SEARCH_TERMS_DESC="For performance reasons, this will not highlight more than 10 different terms in the search results."
COM_FINDER_CONFIG_HILIGHT_CONTENT_SEARCH_TERMS_LABEL="Highlight Search Terms"
COM_FINDER_CONFIG_IMAGE_CLASS_LABEL="Image Class"
COM_FINDER_CONFIG_LANGUAGE_DEFAULT_DEFAULT_LANGUAGE="Default Site Language"
Expand Down
3 changes: 2 additions & 1 deletion components/com_finder/tmpl/search/default_results.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@
<?php // Activate the highlighter if enabled. ?>
<?php if (!empty($this->query->highlight) && $this->params->get('highlight_terms', 1)) : ?>
<?php
// Allow a maximum of 10 tokens to be highlighted. Otherwise the URL can get too long.
$this->document->getWebAssetManager()->useScript('highlight');
$this->document->addScriptOptions(
'highlight',
[[
'class' => 'js-highlight',
'highLight' => $this->query->highlight,
'highLight' => array_slice($this->query->highlight, 0, 10),
]]
);
?>
Expand Down