You are here: Home :: Forum Home :: Modules :: Channel Images :: Thread
I want to hide a div when there are no images in the field pagina_slideshow, which is a Channel Images field.
{if pagina_slideshow == “”} or {if pagina_slideshow != “”} doesn’t work. Any idea?
{if pagina_slideshow == “”}
<div id=“slideshow”>
<!—“previous page” action—>
<a class=“prevPage browse left”></a>
<!—root element for scrollable—>
<div class=“scrollable”>
<div class=“items”> {exp:channel_images:images entry_id=”{entry_id}”} {image:url} {/exp:channel_images:images} </div>
</div>
<!—“next page” action—>
<a class=“nextPage browse right”></a>
<!—wrapper element for the large image—>
<div id=“image_wrap”>
<!—Initially the image is a simple 1x1 pixel transparent GIF—>
/graphics/layout/blank.gif </div>
</div>{/if}
You could do:
{exp:channel_images:images entry_id=”{entry_id}”}
{if '{image:count}' == 1}
<div id=“slideshow”>
<!—“previous page” action—>
<a ></a>
<!—root element for scrollable—>
<div class=“scrollable”>
<div class=“items”>
{/if}
{image:url}
{if '{image:count}' == '{image:total}'}
</div>
<!—“next page” action—>
<a ></a>
<!—wrapper element for the large image—>
<div id=“image_wrap”>
<!—Initially the image is a simple 1x1 pixel transparent GIF—>
/graphics/layout/blank.gif </div>
</div>{/if}
{/exp:channel_images:images}
Let me know if that helps.
Regards,
Brad
No, that’s doesn’t work. The whole div “slideshow” has to be hidden if there are no pictures in the field pagina_slideshow”. See screenshot.
Besides, this is important:
<div class=“items”> {exp:channel_images:images entry_id=”{entry_id}”} {image:url} {/exp:channel_images:images} </div>
The images has to be exact within the div ‘items’.
I’m little confused. Div slideshow would be hidden if there were no channel images. Maybe I am missing what you are trying to do.
Brad
I have uploade 2 screenshots:
1 With images
2 No images, explanation is inside
In my code it is hidden right?
Brad
Here is some extra explanation:
http://expressionengine.com/forums/viewthread/166469/#796839
The thread has moved:
http://expressionengine.com/forums/viewthread/166469/
Please have a look at this comment from the EE moderator:
To be honest I have haven’t often come across a third party fieldtype where I couldn’t test it’s condition.
Unfortunately this looks like an issue with the fieldtype and not with EE persay. What was Brad’s response?
Hello,
Maybe we can make some changes this week to test the fieldtype. We have to customize the code. This is really an issue that was created with the move from 1.6.9 to 2.1 for us with the way EE changed things.
I will keep you in the loop. Still not sure why you can’t do it the way I discuss, but I understand.
Brad
That would be very nice!
I have a new version. Email me and you can test for me. If it works I will put it up for everyone else.
Brad
Hi Brad,
I am using Channel Images 1.6.5 with EE 1.6.8 and wanted to ask if I can use conditionals outside exp:channel_images to test if any images exist or is that only an EE2+ feature?
I need to hide the div that holds the exp:channel_images tag if no images exist.
Thanks!
Hello,
You should be able to test in Channel Images 1.6.6. Have you tried it there?
Brad
I upgraded to 1.6.6, but couldn’t get conditionals to work outside the channel images tags (inside works fine). Here is the code:
{if total_images > 3}
<div>
{exp:channel_images:images entry_id=”{entry_id}” limit=“3” offset=“3”}
{image_url:th}
{/exp:channel_images:images}
</div>
{/if}
The div should only show if there are 4 or more images uploaded via channel images. I also tried using {if ‘{total_images}’ > 3} and {if ‘{image:total}’ > 3} with no luck. Is there a specific field to test for in EE 1.6.8? Or maybe, I am doing something wrong?
Thanks!
Ahh… I think now you can only test if it is empty or not. Not how many there are. You would have to hide the div with the channel:images loop to do this. Just test in the the loop if image:count > 3 then put the div before the first entry and after the last entry.
Brad