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
| Attachment | Size |
|---|---|
| image_gallery.module.patch | 2.63 KB |

#1
Corrected typo in issue tittle.
What should i do to help the maintainer of this module to accept this patch?
#2
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
hetta nailed it 6.x then backport to the 5.x-2.x
#4
marked http://drupal.org/node/216684 as duplicate ...
#5
this would be cool.
#6
i think this still needs to be updated to 6.x
#7
Please find attached the Patch which implements this feature in 6.x-1.dev
#8
#9
Please test attached patch.
#10
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
tried sun's patch, only problem is that the last gallery in $galleries array gets displayed without thumbnail and imagecount.
regards
#12
subscribing
#13
Just a thought about:
<?phpfor ($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
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
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:
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
resetting Status
#17
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.