Jump to:

23486 Posts in 18995 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » If more than 3 images in control

General questions about getting started with SilverStripe that don't fit in any of the categories above.

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

Page: 1
Go to End
Author Topic: 793 Views
  • DeklinKelly
    Community Member
    197 Posts

    If more than 3 images in control Link to this post

    This displays all images in a control:

    <% control CarouselImages %>
    <img src="$Image.URL" alt="$Caption.ATT" />
    <% end_control %>

    But I only want to do a conditional to check if there are more than 3 images:

    <% if CarouselImages >3 %>
    <h1>There are more than three images!</h1>
    <% end_if %>

  • Willr
    Forum Moderator
    5508 Posts

    Re: If more than 3 images in control Link to this post

    You cannot do that in the templates. You would need to write a snippet of PHP

    function Carousel() {
    if($this->CarouselImages()) { if($this->CarouselImages()->TotalItems() > 3) return "Too Many"; }
    return $this->CarouselImages();

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.