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've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Template Questions /

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

peekNext


Go to End


17 Posts   3354 Views

Avatar
Blackthorn87

Community Member, 34 Posts

16 April 2012 at 11:21pm

Hey Guys,

I've been struggling with this situation for a few hours and have read everything I could find online.

What I'm doing is displaying Information from a DataObject to create a carousel (using jCarousel). The part I'm struggling with is displaying a bit of information from the next Item, the name, so basically it says next item is called 'item name'.

I looked on the web for a solution and found something called 'peekNext'. I tried to implement this in the template like so:

<% control Products %>

$productName
$productImage

<% control peekNext %>$productName<% end_control %>

<% end_control %>

But I've had no luck.

Any Help?

Avatar
swaiba

Forum Moderator, 1899 Posts

17 April 2012 at 1:02am

quick google leads me to believe..

<% if Iterator.peekNext %> 

instead of

<% if peekNext %> 

and I'd also advise nivo slider over jcarosel anyday of the week (including today)

Avatar
Blackthorn87

Community Member, 34 Posts

17 April 2012 at 1:10am

Hey swaiba,

I tried what you suggested but it failed on me and caused an error.

I swapped out the

<% control peekNext %>$productName<% end_control %>

for this

<% if Iterator.peekNext %>$productName<% end_if %>

but to no avail. Just got an error.

Avatar
swaiba

Forum Moderator, 1899 Posts

17 April 2012 at 1:14am

yeah my bad - it should work as you have... what does it actually do?

Avatar
Blackthorn87

Community Member, 34 Posts

17 April 2012 at 1:58am

From what I understand it's supposed to allow you pull data from the next data object. At least that is the outcome I would like to achieve.

Avatar
swaiba

Forum Moderator, 1899 Posts

17 April 2012 at 2:08am

yeah i get that bit, I searched the code and it is reight there is DataObjectSet - I meant what does the above template you are using actually do

Avatar
Blackthorn87

Community Member, 34 Posts

17 April 2012 at 2:27am

I'm the process of creating a module and widget set. It creates a dataobject tied to a page type; the data object being a motor home and the page type being a motor home category.

The peekNext part is part of the widget. It is supposed to display all the motor homes regardless of their category page, which it does. But also on each motor home entry i would like it to display the one that is going to appear next.

If you get what I'm trying to explain.

Avatar
swaiba

Forum Moderator, 1899 Posts

17 April 2012 at 2:32am

I get what you are saying - I'm obviously not being clear enough myself.... what is the code when you execute outputing... is it blank? is it erroring? what is exactly is the result of the code?

Go to Top