The attached patch allows hiding empty galleries.
It provides a extra setting option under /admin/settings/image_gallery

See http://www.flickr.com/photos/develoop/tags/hideemptygalleries/ for some screenshots

Comments

demeester_roel@drupal.org’s picture

Title: Iamge gallery. Add option to hide empty galleries » Image gallery. Add option to hide empty galleries

Corrected typo in issue tittle.
What should i do to help the maintainer of this module to accept this patch?

Hetta’s picture

Create a patch for 6.x-whatever, cos that's where new features are going; then make a patch for 5.x-2.x-dev, cos that, too, can take new features.

Here's where he says no more features for 5.x-1.x:
http://drupal.org/node/216684

Can't find the one where he says first 6.x-1-x.dev, then backport to 5.x-2.x, but it's in the issue queue somewhere.

drewish’s picture

Version: 5.x-1.x-dev » 6.x-1.x-dev

hetta nailed it 6.x then backport to the 5.x-2.x

Hetta’s picture

marked http://drupal.org/node/216684 as duplicate ...

yesct’s picture

this would be cool.

drewish’s picture

Status: Needs review » Needs work

i think this still needs to be updated to 6.x

demeester_roel’s picture

StatusFileSize
new2.68 KB

Please find attached the Patch which implements this feature in 6.x-1.dev

demeester_roel@drupal.org’s picture

Status: Needs work » Needs review
sun’s picture

StatusFileSize
new1.97 KB

Please test attached patch.

joachim’s picture

I want to move galleries over to being made with views. This will give much more control over how they are generated and themed.
See http://drupal.org/node/405456 for a patch. Help testing this would be welcome if you are able.

We'd need to add some kind of filter on terms... the count field is already there though.

pebosi’s picture

tried sun's patch, only problem is that the last gallery in $galleries array gets displayed without thumbnail and imagecount.

regards

luco’s picture

subscribing

David Stosik’s picture

Just a thought about:

   for ($i=0; $i < count($galleries); $i++) {
     $galleries[$i]->count = taxonomy_term_count_nodes($galleries[$i]->tid, 'image');
     // Hide empty galleries, if configured.
     if (variable_get('image_gallery_hide_empty_galleries', 0) && !$galleries[$i]->count) {
       unset($galleries[$i]);
       continue;
     } 

What happens to count($galleries) as soon as you unset an element from $galleries?
Maybe it would be better to replace the first line by the two lines:

   $galleries_count = count($galleries);
   for ($i=0; $i < $galleries_count; $i++) {

I didn't test it, it's only a thought. ;)

David

joachim’s picture

Status: Needs review » Closed (fixed)

Technically, a views filter for this isn't possible. I've just written a long explanation of why (you get multiple rows for things that pass), along with how you could do it in theming but it'll be ugly.
But I've had a brainwave :)

Just add a 'Image gallery: Latest image' relationship, and enable 'require this relationship'.
Hey presto! Terms that have no nodes are not shown.

If someone could write this up as a 'howto' in the module documentation pages that would be very helpful.

fischerj’s picture

Using the "required relationship" is a pretty good workaround.

Nevertheless, this does not work if there are only images in a gallery to which a user does not have the rights to watch (via content_access).

I have some galleries with nodes in it, but access for all image nodes in that gallery is only allowed to authenticated users.

Example:

  • gallery1
    • image 1.1 (guest)
    • image 1.2 (guest)
  • gallery2
    • image 2.1 (authenticated)
    • image 2.2 (authenticated)

When using the relationship solution, a guest can still see gallery2, although "there are 0 images in this gallery".

Obviously the counting of the images within the gallery respects the nodes' access restrictions but the relationship does not.

I'm not sure whether this is an image or a views issue? Any ideas?

fischerj’s picture

Version: 6.x-1.x-dev » 6.x-1.0-beta3
Status: Closed (fixed) » Active

resetting Status

joachim’s picture

Status: Active » Closed (fixed)

I would file that as a bug in Views, though I doubt it can easily be fixed, if at all.

This is due to the way the node access rewrites queries -- it can only see a 'select from node' at the start of a query AFAIK.
On D7 with the new DB layer this should be better! :)

So I'm afraid I'm going to close this again.

xsramik’s picture

Version: 6.x-1.0-beta3 » 6.x-1.0-beta6
Assigned: Unassigned » xsramik
Status: Closed (fixed) » Needs work

Please, make this patche on version 6.x-1.0-beta6. Thx

xsramik’s picture

Please, make this patche on version 6.x-1.0-beta6. Thx

xsramik’s picture

Assigned: xsramik » Unassigned
Status: Needs work » Closed (won't fix)