Hide Empty Categories Hide Empty Categories
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Hide Empty Categories

Started by 1aB, December 31, 2010, 04:23:50 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

1aB

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.

Αndré

Well done. Am I right that the modification is to comment out
           $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.

1aB

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... ;-)

Cyrolancer

Just commenting out


echo template_eval($template_noalb, $params);


part seems working to me.

StuartDowling

That plugin worked a treat - thank you  :)

AK_CCM

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

michaelsage

Hi,

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

Thanks


AK_CCM

Hello all,

Quote from: AK_CCM on June 18, 2013, 01:38:50 PM
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

Αndré

I suggest to attach the new version to the initial post.

1aB

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 :-)

astrasuite

Quote from: Cyrolancer on May 17, 2012, 01:03:39 PM
Just commenting out


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 !

pols1337

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. 


AK_CCM

Hello pols1337,

Quote from: pols1337 on December 24, 2013, 07:53:23 AM
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

Αndré

Quote from: AK_CCM on December 24, 2013, 10:06:05 AM
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). 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!