An extension of SilverStripe’s GroupedList that supports traversing relations

Installs: 235

Dependents: 0

Suggesters: 0

Security: 0

Stars: 4

Watchers: 6

Forks: 1

Open Issues: 0


1.0.0 2015-06-09 14:10 UTC

This package is auto-updated.

Last update: 2024-06-04 21:38:31 UTC


Build Status Latest Stable Version Total Downloads License

An extension of SilverStripe’s GroupedList that supports traversing relations.

Note: depending on your data, the same items may be output multiple times. For example if a product belongs to multiple categories, and you group by category title, then the product will show under each of the categories that it belongs to.


composer require bigfork/supergroupedlist ^1.0

Or download and extract to a folder named supergroupedlist in your document root.


Use exactly as you would use GroupedList, but with dot-notation to traverse relations:

public function GroupedProducts() {
	$products = Product::get();
	return SuperGroupedList::create($products);
<% loop $GroupedProducts.GroupedBy('Categories.Title') %>
	<h1>{$Title}</h1><!-- Category title -->
		<% loop $Children %>
			<li>{$Title}</li><!-- Product title -->
		<% end_loop %>
<% end_loop %>

You can traverse has_one, has_many and many_many relations using dot notation. The last part of the notation you provide (Title in the example above) will be both the field that’s extracted from the final component, and the $Variable used to access that field inside the loop.

You can even traverse multiple relations at once. For example, $GroupedProducts.GroupedBy('Manufacturer.Employees.FavouriteTeam.Name') would return a list of products grouped by the names of the favourite teams of the employees of the product’s manufacturer.