From 489f7e0b54c45e0cdfa711104935efe8b90b75bf Mon Sep 17 00:00:00 2001 From: Mikhail Popov Date: Thu, 13 Apr 2017 14:49:20 -0700 Subject: [PATCH] Hold number of search results in a data attribute Current way of counting returned search results (e.g. for Event Logging) relies on counting the appropriate elements in the search results page's DOM, up to the limit the user requested (e.g. 20 by default). This allows us to record the total number and the offset, useful for event logging. For example, if we wanted to know whether the user viewed 2nd or 3rd set of search results. Change-Id: Ic8601e9eeddac84ba8e0d7dc6f127bf360b6f90f --- includes/widget/search/SearchFormWidget.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/widget/search/SearchFormWidget.php b/includes/widget/search/SearchFormWidget.php index a7407a062f..008ed19b38 100644 --- a/includes/widget/search/SearchFormWidget.php +++ b/includes/widget/search/SearchFormWidget.php @@ -103,7 +103,11 @@ class SearchFormWidget { if ( $totalResults > 0 && $offset < $totalResults ) { $html .= Xml::tags( 'div', - [ 'class' => 'results-info' ], + [ + 'class' => 'results-info', + 'data-mw-num-results-offset' => $offset, + 'data-mw-num-results-total' => $totalResults + ], $this->specialSearch->msg( 'search-showingresults' ) ->numParams( $offset + 1, $offset + $numResults, $totalResults ) ->numParams( $numResults ) -- 2.20.1