Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Hey guys,
how can I hide empty galleries from the galleries overview?
Thanks
Yannick
Comments
Comment #1
auris CreditAttribution: auris commentedSimilar needs here. I want a view to display galleries without images.
Comment #2
eL CreditAttribution: eL commentedOMG, empty galleries should not definitely be displayed in overview and on any other public place!
Critical!
May be some reverse node reference to ask, if gallery has any image referenced to this...?
Comment #3
eL CreditAttribution: eL commentedEverybody wants to show ugly empty galleries on frontpage???
Comment #4
skizzo CreditAttribution: skizzo commentedCreate the Gallery as "not published" (Content type's Workflow Settings). Add a triggered rule (Rules module): ON event After saving new content, IF Created content is GALLERY IMAGE, Load a referenced node (Field: field_gallery), Publish Referenced Content (Content: Referenced Content). You could get fancy: add image counter to Gallery (module nodereference_count), then using rules and rule sets you can publish/unpublish the Gallery based on its image count being >= N, so that gallery gets unpublished if all images are removed, if there are too few images, if there are too many images, etc...
Comment #5
eL CreditAttribution: eL commentedskizzo: nice, thanks!
Comment #6
eL CreditAttribution: eL commentedwe should be more specific and make it more usable:
- checking on every image upload, if it belongs to gallery, that is not epmty, is quiet big useless performance impact. Isn't it? Same for re-publishing again and again for new images in the same gallery...
- checking number of images in gallery looks powerfull. We can only do an numeric comparsion, if nodereference-count is bigger than 0 and than set gallery to publish. But this apply only on gallery, that is updated. Not if we upload new (first) image to that gallery (gallery is only referenced from image).
Am I right?
Comment #7
skizzo CreditAttribution: skizzo commented- how many images per hour are you adding? impact on server load might be negligible
- I am not sure I understand your point: you cannot create image unless you have created a gallery first. Before adding image the counter (in gallery node) is zero.
Comment #8
eL CreditAttribution: eL commentedok, may be, it is not so big impact for server...
anyway - your first tip 100 % works. Second, with nodereference count, for me not. But probably I´m only not able to set it right in Rules.
Comment #9
eL CreditAttribution: eL commentedhm, worked fine, unless user deleted all images from gallery... than, this gallery is published, but epmty