Jump to:

3393 Posts in 976 Topics by 852 members

Template Questions

SilverStripe Forums » Template Questions » $Pos % 12

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

Page: 1
Go to End
Author Topic: 298 Views
  • MrChimp
    Avatar
    Community Member
    6 Posts

    $Pos % 12 Link to this post

    Hello

    I currently have two template files as follows:

    ProjectHolder.ss:

    <% control getItems() %>
    <% include ProjectBrief TopPos = $Pos%>
    <% end_control %>

    ProjectBrief.ss:

    $TopPos

    This counts up from 1. What I would like to do is to count up to 12 and then loop back to one again. Basically "$Pos % 12".

    However, I can't use % in the template. I've tried creating a method on the ProjectHolder controller that returns "$this->iteratorPos % 12". This works as long as I don't call it within a control - which I need to. Calling it within a control returns nothing and calling $Top.LoopPos within a control always returns 0.

    Any clues how I can do this?

  • MrChimp
    Avatar
    Community Member
    6 Posts

    Re: $Pos % 12 Link to this post

    Well that was easy.

    $Modulus(value, offset)

    298 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.