News:

Dear forum visitors, if the support forum is not available, please try again a few minutes later. Thanks!

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