Author Topic: number of new photos in categories  (Read 4893 times)

0 Members and 1 Guest are viewing this topic.

Offline alekseyn1

  • Full Member
  • ***
  • Posts: 102
    • View Profile
    • My Project
number of new photos in categories
« 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 (

Code: [Select]
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?



Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: number of new photos in categories
« Reply #1 on: December 23, 2009, 01:09:50 AM »
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.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)