From 8225e1abb80b9f184f10886f5cd7af521316fcb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michael=20Gro=C3=9Fe?= <grosse@cosmocode.de> Date: Fri, 20 Apr 2018 11:26:02 +0200 Subject: [PATCH] fix(search): don't start result position with 2 Also, for consistency this initializes also $num with 0, while ensuring that the first FT_SNIPPET_NUMBER results with a $cnt>0 have a snippet. --- inc/Ui/Search.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/inc/Ui/Search.php b/inc/Ui/Search.php index 33506ad73..3e40b835d 100644 --- a/inc/Ui/Search.php +++ b/inc/Ui/Search.php @@ -565,8 +565,8 @@ class Search extends Ui $html .= '<h2>' . $lang['search_fullresults'] . ':</h2>'; $html .= '<dl class="search_results">'; - $num = 1; - $position = 1; + $num = 0; + $position = 0; foreach ($data as $id => $cnt) { $position += 1; @@ -586,12 +586,12 @@ class Search extends Ui $lastMod .= '<time datetime="' . date_iso8601($mtime) . '" title="'.dformat($mtime).'">' . dformat($mtime, '%f') . '</time>'; $resultBody['meta'] = $lastMod; if ($cnt !== 0) { + $num++; $hits = '<span class="hits">' . $cnt . ' ' . $lang['hits'] . '</span>, '; $resultBody['meta'] = $hits . $resultBody['meta']; - if ($num < FT_SNIPPET_NUMBER) { // create snippets for the first number of matches only + if ($num <= FT_SNIPPET_NUMBER) { // create snippets for the first number of matches only $resultBody['snippet'] = ft_snippet($id, $highlight); } - $num++; } $eventData = [ -- GitLab