Author Topic: Highlight search result on target page  (Read 658 times)

0 Members and 1 Guest are viewing this topic.

Offline Tazzios

  • Jr. Member
  • **
  • Posts: 50
Highlight search result on target page
« on: 14.04.2020 16:05:51 »

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
Code: [Select]

Change line 21
Code: [Select]
<a href="<?php echo JRoute::_($result->href); ?>"<?php if ($result->browsernav == 1) :?> target="_blank"<?php endif;?>>

Code: [Select]
<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  WyJkb3dubG9hZCIsImV4YW1wbGUiLCJkb3dubG9hZCBleGFtc GxlIl0=  > ["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