Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.4] Smart Search: Limiting highlighting of tokens #3006

Closed
jgerman-bot opened this issue Sep 16, 2023 · 0 comments · Fixed by #3007
Closed

[4.4] Smart Search: Limiting highlighting of tokens #3006

jgerman-bot opened this issue Sep 16, 2023 · 0 comments · Fixed by #3007

Comments

@jgerman-bot
Copy link

New language relevant PR in upstream repo: joomla/joomla-cms#41463 Here are the upstream changes:

Click to expand the diff!
diff --git a/administrator/components/com_finder/config.xml b/administrator/components/com_finder/config.xml
index 6cba75fd10fed..cf7e71c3a6a89 100644
--- a/administrator/components/com_finder/config.xml
+++ b/administrator/components/com_finder/config.xml
@@ -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"
 			>
diff --git a/administrator/language/en-GB/com_finder.ini b/administrator/language/en-GB/com_finder.ini
index 5630de653ae4b..2b7d172351f08 100644
--- a/administrator/language/en-GB/com_finder.ini
+++ b/administrator/language/en-GB/com_finder.ini
@@ -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"
diff --git a/components/com_finder/tmpl/search/default_results.php b/components/com_finder/tmpl/search/default_results.php
index d54470559c899..288ab8964f0ea 100644
--- a/components/com_finder/tmpl/search/default_results.php
+++ b/components/com_finder/tmpl/search/default_results.php
@@ -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),
             ]]
         );
     ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

4 participants