Skip to content
Snippets Groups Projects
Unverified Commit 8225e1ab authored by Michael Große's avatar Michael Große
Browse files

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.
parent f0861d1f
No related branches found
No related tags found
No related merge requests found
...@@ -565,8 +565,8 @@ class Search extends Ui ...@@ -565,8 +565,8 @@ class Search extends Ui
$html .= '<h2>' . $lang['search_fullresults'] . ':</h2>'; $html .= '<h2>' . $lang['search_fullresults'] . ':</h2>';
$html .= '<dl class="search_results">'; $html .= '<dl class="search_results">';
$num = 1; $num = 0;
$position = 1; $position = 0;
foreach ($data as $id => $cnt) { foreach ($data as $id => $cnt) {
$position += 1; $position += 1;
...@@ -586,12 +586,12 @@ class Search extends Ui ...@@ -586,12 +586,12 @@ class Search extends Ui
$lastMod .= '<time datetime="' . date_iso8601($mtime) . '" title="'.dformat($mtime).'">' . dformat($mtime, '%f') . '</time>'; $lastMod .= '<time datetime="' . date_iso8601($mtime) . '" title="'.dformat($mtime).'">' . dformat($mtime, '%f') . '</time>';
$resultBody['meta'] = $lastMod; $resultBody['meta'] = $lastMod;
if ($cnt !== 0) { if ($cnt !== 0) {
$num++;
$hits = '<span class="hits">' . $cnt . ' ' . $lang['hits'] . '</span>, '; $hits = '<span class="hits">' . $cnt . ' ' . $lang['hits'] . '</span>, ';
$resultBody['meta'] = $hits . $resultBody['meta']; $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); $resultBody['snippet'] = ft_snippet($id, $highlight);
} }
$num++;
} }
$eventData = [ $eventData = [
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment