Let user choose limit

Hi
What can be the method to let the user choose the limit of displaying items ? For example, the user could enter a number (between 1 and 36) and choose how many items will be display.

count:
    label: Count
    type:  text

Can this technique work with limit() ?

  <?php foreach($page->children()->limit(N_NUMBER_FROM_USER) as $subpage): ?>
  <li>
   ...content...
  </li>
  <?php endforeach ?>

Short answer: yes.

$limit = $page->count()->int();
$posts = $page->children()->limit($limit);

Instead of using a text field, I’d use a number field and use the between validator.

2 Likes

Thanks very much, I didn’t know about between validator.
Bye