Hiding Empty Categories (Private Categories) Hiding Empty Categories (Private Categories)
 

News:

cpg1.5.48 Security release - upgrade mandatory!
The Coppermine development team is releasing a security update for Coppermine in order to counter a recently discovered vulnerability. It is important that all users who run version cpg1.5.46 or older update to this latest version as soon as possible.
[more]

Main Menu

Hiding Empty Categories (Private Categories)

Started by pftq, March 03, 2007, 02:51:24 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pftq

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!

Nibbler

Look at the get_cat_list() album in index.php

pftq

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?

Nibbler

It's defined in a theme's theme.php. If it is not defined it falls back to the definition in themes.inc.php

pftq


pftq

Got it.

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

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