Image gallery. Add option to hide empty galleries

demeester_roel - March 16, 2008 - 10:06
Project:Image
Version:6.x-1.0-beta3
Component:image_gallery
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

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

AttachmentSize
image_gallery.module.patch2.63 KB

#1

demeester_roel@... - April 27, 2008 - 15:50
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?

#2

Hetta - April 27, 2008 - 17:31

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.

#3

drewish - April 28, 2008 - 00:17
Version:5.x-1.x-dev» 6.x-1.x-dev

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

#4

Hetta - April 28, 2008 - 05:33

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

#5

YesCT - June 3, 2008 - 06:35

this would be cool.

#6

drewish - June 6, 2008 - 19:42
Status:needs review» needs work

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

#7

demeester_roel - August 18, 2008 - 15:49

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

AttachmentSize
image_gallery.module.empty_galleries.patch 2.68 KB

#8

demeester_roel@... - November 3, 2008 - 22:52
Status:needs work» needs review

#9

sun - March 9, 2009 - 04:37

Please test attached patch.

AttachmentSize
image.hide-empty-galleries.patch 1.97 KB

#10

joachim - April 12, 2009 - 13:40

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.

#11

pebosi - June 18, 2009 - 10:28

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

regards

#12

luco - September 8, 2009 - 16:52

subscribing

#13

David Stosik - September 8, 2009 - 22:37

Just a thought about:

<?php
  
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:
<?php

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

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

David

#14

joachim - September 9, 2009 - 12:41
Status:needs review» closed

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.

#15

fischerj - October 27, 2009 - 17:21

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?

#16

fischerj - October 27, 2009 - 17:27
Version:6.x-1.x-dev» 6.x-1.0-beta3
Status:closed» active

resetting Status

#17

joachim - October 27, 2009 - 17:38
Status:active» closed

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.

 
 

Drupal is a registered trademark of Dries Buytaert.