Jump to content

Paginate with repeater fields


melissa_boyle
 Share

Recommended Posts

  • 3 months later...

HI,

I have the code below in a page and the repeater works fine.

Is it possible to paginate after a set number of repeats?

<div class="container">
	<div class="row">
		
		<?php foreach($page->children as $c) { ?>

		<div  class="col-xs-6 col-md-4">

				<h3><?php echo $c->title; ?></h3>
				<p><?php echo $c->festivals_body; ?> </p><hr>
			
		</div>
<?php }?>
                

	</div>       <!-- closing row --> 
                              
             <?php $results = $page->children("start=0, limit=9");
                   $pagination = $results->renderPager();
                   echo $pagination; 
             ?>

Thanks

Link to comment
Share on other sites

The code you posted is a simple loop over children, which has nothing to do with repeater-fields. This should work on a template, where pagination is enabled.

<?php 
  $paginatedChildren = $page->children("limit=9"); 
  $pagination = $paginatedChildren->renderPager();
?>
<div class="container">
  <div class="row">
  <?php foreach($paginatedChildren as $c) { ?>
    <div class="col-xs-6 col-md-4">
      <h3><?php echo $c->title; ?></h3>
      <p><?php echo $c->festivals_body; ?> </p><hr>
    </div>
  <?php }?>
  </div><!-- closing row --> 
  <?php echo $pagination; ?>
</div>
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...