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

17 April 2012 at 2:40am

Sorry mate, the result of the above code is nothing.

When I use

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

I get nothing, no errors, no text, etc.

When I use

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

I get

Fatal error: Call to undefined method ArrayIterator::hasValue() in C:\Users\DESKTOP1\AppData\Local\Temp\silverstripe-cacheC--xampp-htdocs-dev_DOM\.cache.module_motorhomes.templates.ProductWidget.ss on line 51

Avatar
swaiba

Forum Moderator, 1899 Posts

17 April 2012 at 2:54am

ok, 1) forget "Iterator.peekNext"

2) ok it does nothing... how about this...

<% if peekNext %>hello world
<% control peekNext %>test $someotherfield $ID $Name<% end_control %>
<% end_if %>

Avatar
Blackthorn87

Community Member, 34 Posts

17 April 2012 at 3:41am

Sorry mate,

That hasn't wielded any results either. But to be honest, I'm entirely sure how to use the peekNext function, can you actually use it in the template, or do I have to use it in the controller/function?

Avatar
Blackthorn87

Community Member, 34 Posts

21 April 2012 at 2:25am

Does anyone have any ideas about this problem?

Avatar
Blackthorn87

Community Member, 34 Posts

30 April 2012 at 8:37pm

Sorry guys, I'm bumping this again.

It would be great if someone could lend a bit of time to solve this, maybe an admin?

Thanks in advance!

Avatar
swaiba

Forum Moderator, 1899 Posts

30 April 2012 at 8:55pm

Blackthorn87,

Firstly rather than saying "That hasn't wielded any results either" you might have indicated whether you could see the word "test" at all - that indicated whether you are going into the contorl structures. Second you could open a debugger and stick a breakpoint on the peekNext function to see what is happending. Third you could post a simple example that completely encapsulates/reproduces the problem because there is so *no* "other stuff" that could be affecting this from working - often the problem is not where you think it is.

And if you are after "Admins" then your only reliable hope is to get on IRC when the core devs are present which they are for one hour a week - or to post on the core dev list (but that is more for development decisions rather than support). I don't see silverstripe employees posting on here at all often.

Best of luck!

Avatar
Blackthorn87

Community Member, 34 Posts

30 April 2012 at 9:02pm

Thanks swaiba,

I'll have another go see what happens, posting it on here afterwards.

Watch this space.

Avatar
Blackthorn87

Community Member, 34 Posts

1 May 2012 at 4:13am

Hey swaiba,

I've done this:

<% if peekNext %>hello world
<% control peekNext %>test $someotherfield $ID $Name<% end_control %>
<% end_if %>

and it doesn't enter the control structures as it doesn't display the word 'test'.

Here is the actual code i am using on my template:

<div class="MotorHomeWidget">
	<div class="nav_holder"></div>
	<ul id="MotorHomeWidget" class="jcarousel-skin-viewrange">
		<% control ViewOurRange %><li class="$EvenOdd<% if First %> first<% end_if %><% if Last %> last<% end_if %>">
			<div class="ViewRangeTitle"><a href="$Link">$Title</a></div>
			<p>$Description.LimitCharacters(80)</p>
			<a href="$Link">$Image.CroppedImage(200,150)</a>
			<% if peekNext %>
			test if statement
			<% control peekNext %>test $Title $ID<% end_control %>
			<% end_if %>
		</li><% end_control %>
	</ul>
</div>

The data the above template is pulling is from a dataobject if that helps.

Also i'm not entirely sure how to:
"open a debugger and stick a breakpoint on the peekNext function"

Some pointing in the right direction on that would also be helpful.

Thanks again.