diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 71d4ba8ebd4bca5f127a9935321de5a505c29ab0..894748183febd8a0d6fd63a865c8c37ccdb82d78 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -69,6 +69,7 @@ Views 6.x-3.x-dev o #629840 by fuerst: Search filter caused bad query on PostgreSQL. o #593668 by neochief: Allow changing of the display ID. o #600242 by pcambra: Allow "search" filter as an argument. + o #387748 by recrit: Allow summaries to be ordered by number of records. Views 6.x-3.0-alpha1 Bugs fixed diff --git a/handlers/views_handler_argument.inc b/handlers/views_handler_argument.inc index 2a71038a6ba2df05909a4958fc00e9dd214d93f9..b6a61b37a4466bce1c8fe39fc12a0982449d6107 100644 --- a/handlers/views_handler_argument.inc +++ b/handlers/views_handler_argument.inc @@ -336,6 +336,20 @@ class views_handler_argument extends views_handler { 'style plugin' => TRUE, 'breadcrumb' => TRUE, // generate a breadcrumb to here ), + 'summary asc by count' => array( + 'title' => t('Summary, sorted by number of records ascending'), + 'method' => 'default_summary', + 'method args' => array('asc', 'num_records'), + 'style plugin' => TRUE, + 'breadcrumb' => TRUE, // generate a breadcrumb to here + ), + 'summary desc by count' => array( + 'title' => t('Summary, sorted by number of records descending'), + 'method' => 'default_summary', + 'method args' => array('desc', 'num_records'), + 'style plugin' => TRUE, + 'breadcrumb' => TRUE, // generate a breadcrumb to here + ), 'default' => array( 'title' => t('Provide default argument'), 'method' => 'default_default', @@ -517,7 +531,7 @@ class views_handler_argument extends views_handler { * If an argument was expected and was not given, in this case, display * a summary query. */ - function default_summary($order) { + function default_summary($order, $by = NULL) { $this->view->build_info['summary'] = TRUE; $this->view->build_info['summary_level'] = $this->options['id']; @@ -531,7 +545,7 @@ class views_handler_argument extends views_handler { $this->query->clear_fields(); $this->summary_query(); - $this->summary_sort($order); + $this->summary_sort($order, $by); // Summaries have their own sorting and fields, so tell the View not // to build these. @@ -622,8 +636,8 @@ class views_handler_argument extends views_handler { * @param $order * The order selected in the UI. */ - function summary_sort($order) { - $this->query->add_orderby(NULL, NULL, $order, $this->name_alias); + function summary_sort($order, $by = NULL) { + $this->query->add_orderby(NULL, NULL, $order, (!empty($by) ? $by : $this->name_alias)); } /**