forum.coppermine-gallery.net

Support => cpg1.5 plugins => cpg1.5.x Support => cpg1.5 plugin contributions => Topic started by: 1aB on December 31, 2010, 04:23:50 pm

Title: Hide Empty Categories
Post by: 1aB on December 31, 2010, 04:23:50 pm
Hi all,

I just implemented this as a plugin:

Hide Empty Categories cleans up the category list on the thumbnail pages by hiding those categories that are empty, regardless whether they really are empty or whether the current user just sees them as empty. Benefit is to avoid end-user confusion with empty categories when they do not have access to anything within them.

Potentially this plugin may conflict with themes that customize theme_display_cat_list(), as that is what I actually customized... well... left out from. Hope the implementation is clean enough.

Roland

Update v1.1:
New option: "Use database check for subcategories?"
If enabled, the plugin will use database queries to find out if a category should be displayed because one of its subcategories has pictures.
This is useful if those subcategories which have the pictures are so deeply nested that they are not displayed in the layout of the higher-level categories.
However, it comes at the cost of needing to do a few additional database queries, so you better enable this only if you need it.
Title: Re: Hide Empty Categories
Post by: Αndré on December 31, 2010, 04:45:32 pm
Well done. Am I right that the modification is to comment out
Code: [Select]
           $params = array(
                    '{CAT_TITLE}' => $category[0],
                    '{CAT_THUMB}' => $category['cat_thumb'],
                    '{CAT_DESC}' => $category[1],
            );
            echo template_eval($template_noalb, $params);
?

If so, I'd suggest to add a new plugin hook (actually a hidden config value should be enough). That way this plugin works for all themes.


Moving thread to plugin contributions board.


I'll add the plugin to the download section and to the plugin page later.
Title: Re: Hide Empty Categories
Post by: 1aB on December 31, 2010, 06:01:02 pm
Right, it strictly speaking consists only of leaving out the commented part. All the rest is original Coppermine code.
Indeed the modification is so minimal that it could also be a mainstream config option.

About plugin hooks, I suppose that makes sense, because I was acutally searching for which of the hooks I would need to utilize for this, just to spot that there wasn't one... ;-)
Title: Re: Hide Empty Categories
Post by: Cyrolancer on May 17, 2012, 01:03:39 pm
Just commenting out

Code: [Select]
echo template_eval($template_noalb, $params);

part seems working to me.
Title: Re: Hide Empty Categories
Post by: StuartDowling on April 30, 2013, 05:48:46 pm
That plugin worked a treat - thank you  :)
Title: Re: Hide Empty Categories
Post by: AK_CCM on June 18, 2013, 01:38:50 pm
The plugin works very well - thanks for contributing. It would be great if any further version displays empty categories which contains subcategories. Because I'm using some nested categories and now the parent categories are hidden.

Regards, Andreas
Title: Re: Hide Empty Categories
Post by: michaelsage on August 11, 2013, 02:15:50 pm
Hi,

I must be being really stupid... Where can I download this plugin from?

Thanks
Title: Re: Hide Empty Categories
Post by: berni on August 11, 2013, 02:42:20 pm
look here michael: forum.coppermine-gallery.net/index.php?action=dlattach;topic=69444.0;attach=33898 (http://forum.coppermine-gallery.net/index.php?action=dlattach;topic=69444.0;attach=33898)
Title: Re: Hide Empty Categories
Post by: AK_CCM on August 15, 2013, 09:34:43 am
Hello all,

It would be great if any further version displays empty categories which contains subcategories. Because I'm using some nested categories and now the parent categories are hidden.

Roland Fulde has enhanced his plugin with an option for nested categories. Please contact him for the new version if you use categories and hidden subcategories.

Regards, Andreas
Title: Re: Hide Empty Categories
Post by: Αndré on August 19, 2013, 02:58:49 pm
I suggest to attach the new version to the initial post.
Title: Re: Hide Empty Categories
Post by: 1aB on September 17, 2013, 12:21:00 am
V1.1 is now attached to the initial post. If v1.0 did not hide your categories correctly, use the new "Use database check for subcategories?" option.

Coppermine code reviewers may notice that what this plugin does, is actually not possible. Well, it is a bit hacked up, and if some future coppermine version should layout the categories and their links in a different way, it could well be that this plugin will fail then. (Can then possibly or possibly not be re-enabled by modification of the plugin's code, but that's future talk to deal with in the future, if anyhow at all.)

For now, try to have some fun with the new version :-)
Title: Re: Hide Empty Categories
Post by: astrasuite on September 19, 2013, 11:32:11 am
Just commenting out

Code: [Select]
echo template_eval($template_noalb, $params);

part seems working to me.

This plugin had a problem with my Curve theme, but your suggestion works very well, thanks !
Title: Re: Hide Empty Categories
Post by: pols1337 on December 24, 2013, 07:53:23 am
Hi there, just wanted to post a potential 'bug' (maybe): when a category contains subcategories that contain albums, the top category disappears completely.  While I suppose the plugin does its job since the top category doesn't contain any pictures, it does contain pictures two levels down. 

 
Title: Re: Hide Empty Categories
Post by: AK_CCM on December 24, 2013, 10:06:05 am
Hello pols1337,

when a category contains subcategories that contain albums, the top category disappears completely.

do you enabled the option "Use database check for subcategories?"

Best regards

Andreas
Title: Re: Hide Empty Categories
Post by: Αndré on January 23, 2014, 03:33:47 pm
do you enabled the option "Use database check for subcategories?"

As of SVN revision 8659 Coppermine should display the correct album and file counter (thread (http://forum.coppermine-gallery.net/index.php/topic,60827.msg372297.html#msg372297)). This change will be part of cpg1.5.28, so this option can be disabled if your gallery runs with cpg1.5.28 (which isn't released yet nor it's scheduled to release it soon).

Everyone feel free to apply the latest fix to your gallery and report any unexpected behavior related to the album / file counter in the bug thread. Thank you!