Commit 931154d0 authored by Nigel McNie's avatar Nigel McNie
Browse files

Put a count of the number of blocktypes in each category on the category tabs....

Put a count of the number of blocktypes in each category on the category tabs. Hide the ones that have not blocktypes in them
parent 84b2fde9
......@@ -439,14 +439,18 @@ class View {
*/
public static function build_category_list($defaultcategory, View $view, $new=0) {
require_once(get_config('docroot') . '/blocktype/lib.php');
$cats = get_records_array('blocktype_category', '', '', 'name');
// Change to a left join to show tabs with no results
$cats = get_records_sql_array('SELECT bc.name, COUNT(bic.*) AS "count"
FROM {blocktype_category} bc
INNER JOIN {blocktype_installed_category} bic ON (bc.name = bic.category)
GROUP BY bc.name
ORDER BY bc.name', array());
$categories = array_map(
create_function(
'$a',
'$a = $a->name;
return array(
"name" => $a,
"title" => call_static_method("PluginBlocktype", "category_title_from_name", $a),
'return array(
"name" => $a->name,
"title" => call_static_method("PluginBlocktype", "category_title_from_name", $a->name) . " (" . $a->count . ")",
);'
),
$cats
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment