Skip to content

Kirby 5.1.2

$nestCollection->group()

Groups the elements by a given field or callback function

$nestCollection->group(string|Closure $field, bool $caseInsensitive = true): Kirby\Cms\NestCollection

Parameters

Name Type Default
$fieldrequired stringorClosure no default value
$caseInsensitive bool true

Return type

Kirby\Cms\NestCollection

A new collection with an element for each group and a subcollection in each group

This method does not modify the existing $nestcollection object but returns a new object with the changes applied. Learn more →

Exceptions

Type Description
Exception if $field is not a string nor a callback function

Parent class

Kirby\Cms\NestCollection inherited from Kirby\Toolkit\Collection