Jump to:

17452 Posts in 4473 Topics by 1971 members

Archive

SilverStripe Forums » Archive » Peeking ahead in a DataObjectSet

Our old forums are still available as a read-only archive.

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

Page: 1
Go to End
Author Topic: 1357 Views
  • UncleCheese
    Avatar
    4085 Posts

    Peeking ahead in a DataObjectSet Link to this post

    I know it's possible to "peek" ahead or behind in a DataObjectSet. That is, look at the next or previous record without changing the iterator. What I'm wondering is, how do I use this function? What I'd like to do is when my DOSet is in a control, I need to make a decision while in the loop that depends on the next record. For instance, if the value of the next record is the same as the current record, open a new div.. otherwise, don't.

    Does that make sense? And if so, is this supported?

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: Peeking ahead in a DataObjectSet Link to this post

    never really used it but having alot at DataObjectSet.php there is a peekNext() method and a peekPrev() ?

  • UncleCheese
    Avatar
    4085 Posts

    Re: Peeking ahead in a DataObjectSet Link to this post

    Yeah, that looks right, but I guess I'm not sure how to use it in a template. Could it be as simple as

    <% control MyDOs %>
    <% control peekNext %>
    <% if Value = peekPrev.Value %>
    do something
    <% end_if %>
    <% end_control %>

  • Ingo
    Avatar
    Forum Moderator
    801 Posts

    Re: Peeking ahead in a DataObjectSet Link to this post

    Lazy loading is on the todo list, we've brainstormed and created a development plan:
    http://open.silverstripe.com/wiki/development/NewDataMapper

    Would be great to get your feedback through the dev mailinglist (http://groups.google.com/group/silverstripe-dev)

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