News:

Support for jDownloads 3 has been ended
Since 17 August 2023 Joomla.org has discontinued support for Joomla 3.x. Therefore, we will no longer offer official support for our Joomla 3 jDownloads version 3.9.x from January 2024.
Please update your website to the latest Joomla version (Joomla 4 or Joomla 5) as soon as possible. Afterwards, please update jDownloads to the latest published version. The longer you delay, the more difficult the upgrade process for your website is likely to be.

Main Menu
Support-Forum

Highlight search result on target page

Started by Tazzios, 14.04.2020 16:05:51

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Tazzios




the builtin search does not highlight keywords on the target pages link smartsearch does to fix this:

edit file components/com_jdownloads/views/search/tmpldefault_results.php:
add at line 12

<?php 
$searchword
base64_encode(htmlspecialchars($_POST["searchword"]));
?>



Change line 21

<a href="<?php echo JRoute::_($result->href); ?>"<?php if ($result->browsernav == 1) :?> target="_blank"<?php endif;?>>


to:

<a href="<?php echo JRoute::_($result->href); ?>?highlight=<?php echo $searchword ?>"<?php if ($result->browsernav == 1) :?> target="_blank"<?php endif;?>>


It is not 100%

For example
input: download example
mine code WyJkb3dubG9hZCBleGFtcGxlIl0= > ["download example"]
smartsearch  WyJkb3dubG9hZCIsImV4YW1wbGUiLCJkb3dubG9hZCBleGFtcGxlIl0=  > ["download","example","download example"]

I played a bit with JHtml::_('behavior.highlighter', $array) but couldn`t get it to work. Maybe it is even the wrong function.  :P