Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

All other Modules

Discuss all other Modules here.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Image uploads in seperate content div


Reply

3 Posts   648 Views

Avatar
neilos

7 October 2010 at 5:34am Community Member, 19 Posts

Sorry if its been done, but I couldn't find it.

What I have atm is a seperate tab for up to 6 images to be added on a page, but seperate from main content.
ArticlePage.ss

<div id="gallery">
<a rel="lightbox" class="lightbox" href="$Photo.URL">$Photo.SetWidth(130)</a>
<a rel="lightbox" class="lightbox" href="$Photo2.URL">$Photo2.SetWidth(130)</a>
<a rel="lightbox" class="lightbox" href="$Photo3.URL">$Photo3.SetWidth(130)</a><br />
<a rel="lightbox" class="lightbox" href="$Photo4.URL">$Photo4.SetWidth(130)</a>
<a rel="lightbox" class="lightbox" href="$Photo5.URL">$Photo5.SetWidth(130)</a>
<a rel="lightbox" class="lightbox" href="$Photo6.URL">$Photo6.SetWidth(130)</a>
</div>

What i can't figure out how to do is;

<div id="gallery">
<% if there is actually an image uploaded then display this %>
<a rel="lightbox" class="lightbox" href="$Photo.URL">$Photo.SetWidth(130)</a>
<% end_if %>... etc for other images below.
<a rel="lightbox" class="lightbox" href="$Photo2.URL">$Photo2.SetWidth(130)</a>
<a rel="lightbox" class="lightbox" href="$Photo3.URL">$Photo3.SetWidth(130)</a><br />
<a rel="lightbox" class="lightbox" href="$Photo4.URL">$Photo4.SetWidth(130)</a>
<a rel="lightbox" class="lightbox" href="$Photo5.URL">$Photo5.SetWidth(130)</a>
<a rel="lightbox" class="lightbox" href="$Photo6.URL">$Photo6.SetWidth(130)</a>
</div>

Right now it displays 6 images in lightbox regardless if 6 images have been uploaded or not.

Any ideas? I've been on this for a few hours alone.

Avatar
UncleCheese

7 October 2010 at 7:06am 4085 Posts

<% if Photo %>
<a rel="lightbox" class="lightbox" href="$Photo.URL">$Photo.SetWidth(130)</a>
<% end_if %>

<% if Photo2 %>
<a rel="lightbox" class="lightbox" href="$Photo2.URL">$Photo2.SetWidth(130)</a>
<% end_if %>

--------------------
SilverStripe tips, tutorials, screencasts and more: http://www.leftandmain.com

Avatar
neilos

7 October 2010 at 8:21pm Community Member, 19 Posts

Thanks UncleCheese, it is a privilege.

Sometimes solutions are far too simple.

Keep up the good work.