forum.coppermine-gallery.net

Support => cpg1.4.x Support => Older/other versions => cpg1.4 miscellaneous => Topic started by: pftq on March 03, 2007, 02:51:24 am

Title: Hiding Empty Categories (Private Categories)
Post by: pftq on March 03, 2007, 02:51:24 am
I've done some searching but all I've found is that it's not possible/featured.

Basically what I see is that categories are not being hidden if they are empty.  They would be empty, for example, if none of the albums in it are visible.

What DOES work at the moment is the album count.  So I'm thinking if Category's album count is 0, it would not show up in the index.

I don't mind doing the work myself to add this in, nor do I need it featured in config file.  I just need to know what file/function to edit though.  Could someone please point me in the right direction?

What function determines the number of albums in a category and what is the function that lists the categories? (Also what file they're in)

Thanks!
Title: Re: Hiding Empty Categories (Private Categories)
Post by: Nibbler on March 03, 2007, 03:22:37 am
Look at the get_cat_list() album in index.php
Title: Re: Hiding Empty Categories (Private Categories)
Post by: pftq on March 03, 2007, 03:43:28 am
I don't think that's quite it... I'm looking for where the gallery actually goes through and echos the information.

I think it might be this one: theme_display_cat_list

Where is that located?
Title: Re: Hiding Empty Categories (Private Categories)
Post by: Nibbler on March 03, 2007, 03:51:30 am
It's defined in a theme's theme.php. If it is not defined it falls back to the definition in themes.inc.php
Title: Re: Hiding Empty Categories (Private Categories)
Post by: pftq on March 03, 2007, 03:54:13 am
Ah okay thanks. :)
Title: Re: Hiding Empty Categories (Private Categories)
Post by: pftq on March 03, 2007, 04:17:16 am
Got it.

For those interested, add this function to the themes.php in your Theme:

Code: [Select]
function theme_display_cat_list($breadcrumb, &$cat_data, $statistics)
{
    global $template_cat_list, $lang_cat_list;
    if (count($cat_data) > 0) {
        starttable('100%');
        $template = template_extract_block($template_cat_list, 'header');
        $params = array('{CATEGORY}' => $lang_cat_list['category'],
            '{ALBUMS}' => $lang_cat_list['albums'],
            '{PICTURES}' => $lang_cat_list['pictures'],
            );
        echo template_eval($template, $params);
    }

    $template_noabl = template_extract_block($template_cat_list, 'catrow_noalb');
    $template = template_extract_block($template_cat_list, 'catrow');
    foreach($cat_data as $category) {
        if (!isset($category['cat_thumb'])) { $category['cat_thumb'] = ''; }
        if (count($category) == 3) {
            $params = array('{CAT_TITLE}' => $category[0],
                    '{CAT_THUMB}' => $category['cat_thumb'],
                '{CAT_DESC}' => $category[1]
                );
            if($category[3]>0) echo template_eval($template_noabl, $params);
        } elseif (isset($category['cat_albums']) && ($category['cat_albums'] != '')) {
            $params = array('{CAT_TITLE}' => $category[0],
                '{CAT_THUMB}' => $category['cat_thumb'],
                '{CAT_DESC}' => $category[1],
                '{CAT_ALBUMS}' => $category['cat_albums'],
                '{ALB_COUNT}' => $category[2],
                '{PIC_COUNT}' => $category[3],
                );
            if($category[3]>0) echo template_eval($template, $params);
        } else {
            $params = array('{CAT_TITLE}' => $category[0],
                '{CAT_THUMB}' => $category['cat_thumb'],
                '{CAT_DESC}' => $category[1],
                '{CAT_ALBUMS}' => '',
                '{ALB_COUNT}' => $category[2],
                '{PIC_COUNT}' => $category[3],
                );
            if($category[3]>0) echo template_eval($template, $params);
        }
    }

    if ($statistics && count($cat_data) > 0) {
        $template = template_extract_block($template_cat_list, 'footer');
        $params = array('{STATISTICS}' => $statistics);
        echo template_eval($template, $params);
    }


    if (count($cat_data) > 0)
          endtable();
        echo template_extract_block($template_cat_list, 'spacer');
}

Basically, in foreach($cat_data as $category) {...}, add if($category[3]>0) before each echo template_eval