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.

We're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

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

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

Peeking ahead in a DataObjectSet

Go to End

4 Posts   1734 Views


Forum Moderator, 4102 Posts

23 September 2008 at 8:41am

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?


Forum Moderator, 5523 Posts

23 September 2008 at 3:58pm

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


Forum Moderator, 4102 Posts

24 September 2008 at 1:16am

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


Forum Moderator, 801 Posts

25 September 2008 at 10:48pm

Lazy loading is on the todo list, we've brainstormed and created a development plan:

Would be great to get your feedback through the dev mailinglist (