Jump to:

10848 Posts in 2516 Topics by 1792 members

All other Modules

SilverStripe Forums » All other Modules » Image uploads in seperate content div

Discuss all other Modules here.

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

Page: 1
Go to End
Author Topic: 597 Views
  • neilos
    Avatar
    Community Member
    19 Posts

    Image uploads in seperate content div Link to this post

    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.

  • UncleCheese
    Avatar
    4085 Posts

    Re: Image uploads in seperate content div Link to this post

    <% 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

  • neilos
    Avatar
    Community Member
    19 Posts

    Re: Image uploads in seperate content div Link to this post

    Thanks UncleCheese, it is a privilege.

    Sometimes solutions are far too simple.

    Keep up the good work.

    597 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.