Skip to content

Kirby 5.0.4

$pages->groupBy()

$pages->groupBy(...$args)

Parameters

Name Type Default
...$args mixed no default value

Parent class

Kirby\Cms\Pages inherited from Kirby\Toolkit\Collection

Examples

<?php
$years = page('projects')->children()->groupBy('year');
foreach($years as $year => $items): ?>
    <h2><?= $year ?></h2>
    <ul>
      <?php foreach($items as $item): ?>
      <li><?= $item->title() ?></li>
      <?php endforeach; ?>
    </ul>
<?php endforeach ?>