From: Mikhail Popov Date: Thu, 13 Apr 2017 21:49:20 +0000 (-0700) Subject: Hold number of search results in a data attribute X-Git-Tag: 1.31.0-rc.0~3452^2 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles%22%2C%22id_article=%24id_article%22%29%20.%20%22?a=commitdiff_plain;h=489f7e0b54c45e0cdfa711104935efe8b90b75bf;p=lhc%2Fweb%2Fwiklou.git 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 --- 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 )