4images Forum & Community
General / Allgemeines => Programming => Topic started by: alekseyn1 on December 22, 2009, 06:46:40 PM
-
Gents,
I have been trying to show the number of new images in every category...
I came up with this modification of function.php (
function get_categories($cat_id = 0) {
....
foreach ($visible_cat_cache as $key => $category_id) {
$categories .= "<tr>\n<td valign=\"top\">\n";
$is_new = (isset($new_image_cache[$category_id]) && $new_image_cache[$category_id] > 0) ? 1 : 0;
$num_images = (isset($cat_cache[$category_id]['num_images'])) ? $cat_cache[$category_id]['num_images'] : 0;
$num_new_images = (isset($new_image_cache[$category_id]['new_images'])) ? $new_image_cache[$category_id]['new_images'] : 0;
$subcat_ids = array();
get_subcat_ids($category_id, $category_id, $cat_parent_cache);
if (isset($subcat_ids[$category_id])) {
foreach ($subcat_ids[$category_id] as $val) {
if (isset($new_image_cache[$val]) && $new_image_cache[$val] > 0) {
$is_new = 1;
$num_new_images += $new_image_cache[$val]['new_images'];
}
if (isset($cat_cache[$val]['num_images'])) {
$num_images += $cat_cache[$val]['num_images'];
}
}
}
....
"num_new_images" => $num_new_images
...
}
but for some reason some categories do not properly show the number of new images....
anyone has a better solution?
-
You are using unexisting key of new images array.
it should be:
$num_new_images = (isset($new_image_cache[$category_id])) ? $new_image_cache[$category_id] : 0;
there is no ['new_images']
other then that, the rest looks fine.