There is this view of which I configured the fields as follows:
Gallery images: exclude from display - Background: in cck, this is a separate image field with multiple values called 'Gallery images'
Title: default
Custom text:
- Exclude from display
- No results behavior: Hide if empty checked
+ Hide rewriting if empty checked
Colorbox trigger:
- trigger field: custom text
- popup: [field_project_gallery_images]
- No results behavior: Hide if empty checked
+ Hide rewriting if empty checked
This works nicely in itself, colorbox shows a nice slideshow after clicking on the custom text. The problem is that the colorbox trigger should only be output if there are actually images uploaded to the gallery images field. I other words, Hide rewriting if empty checked leaves me with no success.
Which isn't a surprise when dpm($fields)
. It shows the gallery images field as one chunk of HTML entirely instead of an array. dpm($fields)
output comes down to the following if that makes sense:
<?php
$fields['colorobox']['content']['<span class="field-content"><a href="/en?width=100%25&height=100%25&inline=true#colorbox-inline-3" class="colorbox-inline" rel="">Meer foto's</a><div style="display: none;"><div id="colorbox-inline-3"><div id="field-slideshow-3-wrapper" class="field-slideshow-wrapper"> <div class="field-slideshow field-slideshow-3 effect-fade timeout-0 with-pager with-controls" style="width:680px; height:380px"> <div class="field-slideshow-slide field-slideshow-slide-1 even first"> <img class="field-slideshow-image field-slideshow-image-1" typeof="foaf:Image" src="http://multitech.id2r.net/sites/default/files/styles/colorbox_trigger/public/sd14-la-001_0.jpg?itok=8h7_PaP3" width="680" height="380" alt="" /> </div> <div class="field-slideshow-slide field-slideshow-slide-2 odd" style="display:none;"> <img class="field-slideshow-image field-slideshow-image-2" typeof="foaf:Image" src="http://multitech.id2r.net/sites/default/files/styles/colorbox_trigger/public/sd14-la-002_0.jpg?itok=as53SCju" width="680" height="380" alt="" /> </div> <div class="field-slideshow-slide field-slideshow-slide-3 even last" style="display:none;"> <img class="field-slideshow-image field-slideshow-image-3" typeof="foaf:Image" src="http://multitech.id2r.net/sites/default/files/styles/colorbox_trigger/public/sd14-la-003.jpg?itok=PtCO9nvK" width="680" height="380" alt="" /> </div> </div> <div id="field-slideshow-3-controls" class="field-slideshow-controls"> <a href="#" class="prev">Prev</a> <a href="#" class="next">Next</a> </div> </div> </div></div></span>']
?>
No wonder there is no 0
to interpret as an empty field. This way, I can't loop through it and hide if count 0
. To count the characters of the HTML would be way too dirty. But then, what can I do?