Advanced search  

News:

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

Pages: [1]   Go Down

Author Topic: Hide Empty Categories  (Read 11136 times)

0 Members and 1 Guest are viewing this topic.

1aB

  • Contributor
  • Coppermine novice
  • ***
  • Country: de
  • Offline Offline
  • Posts: 29
    • Home Page
Hide Empty Categories
« 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.
« Last Edit: September 17, 2013, 12:14:24 am by 1aB »
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15369
Re: Hide Empty Categories
« Reply #1 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.
Logged

1aB

  • Contributor
  • Coppermine novice
  • ***
  • Country: de
  • Offline Offline
  • Posts: 29
    • Home Page
Re: Hide Empty Categories
« Reply #2 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... ;-)
Logged

Cyrolancer

  • Contributor
  • Coppermine novice
  • ***
  • Offline Offline
  • Posts: 25
Re: Hide Empty Categories
« Reply #3 on: May 17, 2012, 01:03:39 pm »

Just commenting out

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

part seems working to me.
Logged

StuartDowling

  • Coppermine newbie
  • Offline Offline
  • Posts: 2
Re: Hide Empty Categories
« Reply #4 on: April 30, 2013, 05:48:46 pm »

That plugin worked a treat - thank you  :)
Logged

AK_CCM

  • Coppermine regular visitor
  • **
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 63
  • Mushroom Hobby Photograph
    • Ent◊l◊ma.de – Rötlinge, Wiesenpilze und andere Schwammerln
Re: Hide Empty Categories
« Reply #5 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
Logged

michaelsage

  • Coppermine newbie
  • Offline Offline
  • Posts: 1
Re: Hide Empty Categories
« Reply #6 on: August 11, 2013, 02:15:50 pm »

Hi,

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

Thanks
Logged

berni

  • Coppermine regular visitor
  • **
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 99
    • Max und seine Untertanen
Logged

AK_CCM

  • Coppermine regular visitor
  • **
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 63
  • Mushroom Hobby Photograph
    • Ent◊l◊ma.de – Rötlinge, Wiesenpilze und andere Schwammerln
Re: Hide Empty Categories
« Reply #8 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
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15369
Re: Hide Empty Categories
« Reply #9 on: August 19, 2013, 02:58:49 pm »

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

1aB

  • Contributor
  • Coppermine novice
  • ***
  • Country: de
  • Offline Offline
  • Posts: 29
    • Home Page
Re: Hide Empty Categories
« Reply #10 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 :-)
Logged

astrasuite

  • Coppermine newbie
  • Offline Offline
  • Posts: 19
Re: Hide Empty Categories
« Reply #11 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 !
Logged

pols1337

  • Coppermine frequent poster
  • ***
  • Country: us
  • Offline Offline
  • Gender: Male
  • Posts: 240
Re: Hide Empty Categories
« Reply #12 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. 

 
Logged

AK_CCM

  • Coppermine regular visitor
  • **
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 63
  • Mushroom Hobby Photograph
    • Ent◊l◊ma.de – Rötlinge, Wiesenpilze und andere Schwammerln
Re: Hide Empty Categories
« Reply #13 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
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15369
Re: Hide Empty Categories
« Reply #14 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). 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!
Logged
Pages: [1]   Go Up
 

Page created in 0.021 seconds with 21 queries.