Support

Account

Home Forums Add-ons Repeater Field Previous and next field in repeater Reply To: Previous and next field in repeater

  • Hi,

    if you look at the code i posted, you’d need to change your code as following:

    1. store the total repeater count before you run the foreach loop:
    $blocksCount = count($blocks);

    2. add the index when you are doing the foreach:
    <?php foreach( $blocks as $index => $block ) :

    3. your next and previous row will be the following:
    $previousRow = $index == 0? null : $blocks[$index - 1];
    $nextRow = $index == ($blocksCount - 1)? null : $blocks[$index + 1];

    4. now you can get the title of the previous and next like so:
    $previousTitle = $previousRow['fb_title'];
    $nextTitle = $nextRow['fb_title'];

    Cheers.