Jump to:

3434 Posts in 1026 Topics by 866 members

Template Questions

SilverStripe Forums » Template Questions » peekNext

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

Page: 1 2 3
Go to End
Author Topic: 1264 Views
  • Blackthorn87
    Avatar
    Community Member
    27 Posts

    Re: peekNext Link to this post

    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

  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Re: peekNext Link to this post

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

  • Blackthorn87
    Avatar
    Community Member
    27 Posts

    Re: peekNext Link to this post

    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?

  • Blackthorn87
    Avatar
    Community Member
    27 Posts

    Re: peekNext Link to this post

    Does anyone have any ideas about this problem?

  • Blackthorn87
    Avatar
    Community Member
    27 Posts

    Re: peekNext Link to this post

    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!

  • swaiba
    Avatar
    Forum Moderator
    1784 Posts

    Re: peekNext Link to this post

    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!

  • Blackthorn87
    Avatar
    Community Member
    27 Posts

    Re: peekNext Link to this post

    Thanks swaiba,

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

    Watch this space.

  • Blackthorn87
    Avatar
    Community Member
    27 Posts

    Re: peekNext Link to this post

    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.

    1264 Views
Page: 1 2 3
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.