2017 © Pedro PelĆ”ez
 

silverstripe-module supergroupedlist

An extension of SilverStripe’s GroupedList that supports traversing relations

image

bigfork/supergroupedlist

An extension of SilverStripe’s GroupedList that supports traversing relations

  • Thursday, April 13, 2017
  • by kinglozzer
  • Repository
  • 4 Watchers
  • 4 Stars
  • 121 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 5 % Grown

The README.md

SuperGroupedList

Build Status Latest Stable Version Total Downloads License, (*1)

An extension of SilverStripe’s GroupedList that supports traversing relations., (*2)

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., (*3)

Installation

composer require bigfork/supergroupedlist ^1.0

Or download and extract to a folder named supergroupedlist in your document root., (*4)

Usage

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

public function GroupedProducts() {
    $products = Product::get();
    return SuperGroupedList::create($products);
}
<% loop $GroupedProducts.GroupedBy('Categories.Title') %>
    <h1>{$Title}</h1><!-- Category title -->
    <ul>
        <% loop $Children %>
            <li>{$Title}</li><!-- Product title -->
        <% end_loop %>
    </ul>
<% 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., (*6)

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., (*7)

The Versions

13/04 2017

dev-master

9999999-dev https://github.com/bigfork/supergroupedlist

An extension of SilverStripe’s GroupedList that supports traversing relations

  Sources   Download

BSD-3-Clause

The Requires

 

silverstripe list groupedlist grouped

09/06 2015

1.0.0

1.0.0.0 https://github.com/bigfork/supergroupedlist

An extension of SilverStripe’s GroupedList that supports traversing relations

  Sources   Download

BSD-3-Clause

The Requires

 

silverstripe list groupedlist grouped

09/06 2015

0.0.1

0.0.1.0 https://github.com/bigfork/supergroupedlist

An extension of SilverStripe’s GroupedList that supports traversing relations

  Sources   Download

BSD-3-Clause

The Requires

 

silverstripe list groupedlist grouped