diff --git a/include/config_default.inc.php b/include/config_default.inc.php index dc799a0ef..4591a08bf 100644 --- a/include/config_default.inc.php +++ b/include/config_default.inc.php @@ -643,6 +643,19 @@ $conf['tags_default_display_mode'] = 'cloud'; // tag_letters_column_number: how many columns to display tags by letter $conf['tag_letters_column_number'] = 4; +// +-----------------------------------------------------------------------+ +// | Related albums | +// +-----------------------------------------------------------------------+ + +// beyond this limit, do not try to find related albums. If there are too +// many items, the SQL query will be slow and the results irrelevant, +// because showing too many related albums. +$conf['related_albums_maximum_items_to_compute'] = 1000; + +// once found the related albums, how many to show in the menubar? We take +// the heaviest (with more relations). +$conf['related_albums_display_limit'] = 20; + // +-----------------------------------------------------------------------+ // | Notification by mail | // +-----------------------------------------------------------------------+ diff --git a/include/functions_category.inc.php b/include/functions_category.inc.php index f32982473..64f1137a8 100644 --- a/include/functions_category.inc.php +++ b/include/functions_category.inc.php @@ -718,9 +718,9 @@ SELECT function get_related_categories_menu($items, $excluded_cat_ids=array()) { - global $page; + global $page, $conf; - $common_cats = get_common_categories($items, null, $excluded_cat_ids); + $common_cats = get_common_categories($items, $conf['related_albums_display_limit'], $excluded_cat_ids); // echo '
'; print_r($common_cats); echo ''; if (count($common_cats) == 0) diff --git a/include/menubar.inc.php b/include/menubar.inc.php index 46fd265bc..5729ac1df 100644 --- a/include/menubar.inc.php +++ b/include/menubar.inc.php @@ -104,7 +104,12 @@ function initialize_menu() //------------------------------------------------------------ related categories $block = $menu->get_block('mbRelatedCategories'); - if ($block != null and !empty($page['items'])) + if ( + isset($page['items']) + and count($page['items']) < $conf['related_albums_maximum_items_to_compute'] + and $block != null + and !empty($page['items']) + ) { $exclude_cat_ids = array(); if (isset($page['category']))