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.

Archive /

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

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

Peeking ahead in a DataObjectSet


Reply


4 Posts   1381 Views

Avatar
UncleCheese

Forum Moderator, 4092 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?

Avatar
Willr

Forum Moderator, 5513 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() ?

Avatar
UncleCheese

Forum Moderator, 4092 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 %>

Avatar
Ingo

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:
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)