Don't display empty categories Don't display empty 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

Don't display empty categories

Started by Gert-Paul, August 08, 2006, 11:52:30 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

Gert-Paul

I have a gallery where most albums are only visible for logged in users. I want to make some galleries public, but then the guest users see all the other empty categories. Is it possible that the categorie is not shown if there are no albums in it?

I already looked at the template function (theme_display_cat_list, isn't it?) which displays the categories. Is there a function to check if a category is empty? I already searched the forum/internet, but couldn't find a solution.

Joachim Müller

No, permissions are assigned by album, not by category.

Gert-Paul

Quote from: GauGau on August 09, 2006, 06:52:06 AM
No, permissions are assigned by album, not by category.
Has this something to do with permissions?

It can also be useful to hide categories if there are no albums for a special category.

I just looked better at the code and I noticed e.g. $category[2] is printed, which is filled in {ALB_COUNT} in the template. Can't I use this to check if a category has any album and otherwise don't fill the template?

Joachim Müller

Quote from: Gert-Paul on August 09, 2006, 02:19:03 PM
Has this something to do with permissions?
permissions to view, to be more accurate. Categories are container objects that will display no matter what. It doesn't matter if they contain albums or not. It doesn't matter if the albums within a category are viewable by the current visitor - he'll see the category anyway. The only exception is the "user galleries" category - it will only be displayed if there is at least one non-empty album inside it.

Gert-Paul

Ok, I understand. But it is not exactly what I meant with my last comment. In Coppermine you can see the number of Albums inside a category, which is different for different types of users. In my gallery guests see e.g. nothing for the number of albums in a category. I think that in such a case it would be a nice core feature to don't display them if coppermine will display otherwise no albums inside.

I started looking at the code I mentioned in my previous post and I found a quick solution. If if a real hack, because at the bottom of the page still the total number of categories is shown.

Here a small part of the code I used. The part below the foreach loop is edited. First there is a check now if we have a empty category.

...
   //part of theme_display_cat_list()
    $template_noabl = template_extract_block($template_cat_list, 'catrow_noalb');
    $template = template_extract_block($template_cat_list, 'catrow');
    foreach($cat_data as $category) {
        if ($category[2]<1){
       
        // Do nothing...
       
        }
        elseif (count($category) == 3) {
            $params = array('{CAT_TITLE}' => $category[0],
                    '{CAT_THUMB}' => $category['cat_thumb'],
                '{CAT_DESC}' => $category[1]
                );
...


This is also what I had in mind with my previous post.

Maybe this example explains a bit better what I want. I will try to polish this some more, so that Coppermine also displays the right count and some other thing that I maybe think of.