29
0
mirror of https://github.com/joomla/joomla-cms.git synced 2024-06-25 23:02:55 +00:00

[4.4] Smart Search: Limiting highlighting of tokens (#41463)

* Smart Search: Limiting highlighting of tokens

* Update components/com_finder/tmpl/search/default_results.php

Co-authored-by: Quy <quy@nomonkeybiz.com>

* Adding inline help text

---------

Co-authored-by: Quy <quy@nomonkeybiz.com>
Co-authored-by: Olivier Buisard <olivier.buisard@simplifyyourweb.com>
Co-authored-by: Allon Moritz <allon.moritz@digital-peak.com>
Co-authored-by: Martin Carl Kopp <6154099+MacJoom@users.noreply.github.com>
This commit is contained in:
Hannes Papenberg 2023-09-15 10:38:52 +02:00 committed by GitHub
parent b04c168b49
commit ec426c522c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 1 deletions

View File

@ -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"
>

View File

@ -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"

View File

@ -55,12 +55,13 @@ use Joomla\CMS\Uri\Uri;
<?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),
]]
);
?>