2017 © Pedro PelĂĄez
 

neos-package groupby

FlowQuery groupBy operation to group arrays by EEL discriminator

image

dimaip/groupby

FlowQuery groupBy operation to group arrays by EEL discriminator

  • Wednesday, February 1, 2017
  • by dimaip
  • Repository
  • 1 Watchers
  • 5 Stars
  • 2,004 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 5 Versions
  • 10 % Grown

The README.md

Dimaip.GroupBy

FlowQuery groupBy operation to group arrays by EEL discriminator, (*1)

Once upon a time I had a list of persons nodes, and I needed to group them by first letter. So I decided there should be a generic way to group array of nodes into subgroups, based on an EEL expression... And here it is!, (*2)

TL;DR

Install: composer require dimaip/groupby, (*3)

Use:, (*4)

groupedNodesByFirstLetterOfLastName = ${q(nodes).groupBy('String.substring(node.properties.lastName, 0, 1)')}

Full example

Once you have grouped the nodes, you can render them any way you like: with Fluid (yikes!) or with Fusion (yay!)., (*5)

prototype(Name.Space:GroupedList) < prototype(TYPO3.TypoScript:Collection) {
    @process.tmpl = ${'<div class="grouped-list">' + value + '</div>'}
    @context.nodes = ${q(site).find('[instanceof Name.Space:Person]')}
    collection = ${nodes.groupBy('String.substring(node.properties.lastName, 0, 1)')}
    itemName = 'nodes'
    itemKey = 'firstLetter'
    itemRenderer = TYPO3.TypoScript:Collection {
        @process.tmpl = ${'<div><h2>' + firstLetter + '</h2><ul>' + value + '</ul></div>'}
        collection = ${nodes}
        itemName = 'node'
        itemRenderer = ${'<li>' + node.properties.firstName + ' ' + node.properties.lastName + '</li>'}
    }
}

In a similar way you can group nodes based on a very complex EEL expressions, let your imagination fly!, (*6)

Credit

Initial development sponsored by Stefan JohÀnntgen, (*7)

The Versions

01/02 2017

dev-master

9999999-dev

FlowQuery groupBy operation to group arrays by EEL discriminator

  Sources   Download

GPL-3.0+

The Requires

 

01/02 2017

v2.0

2.0.0.0

FlowQuery groupBy operation to group arrays by EEL discriminator

  Sources   Download

GPL-3.0+

The Requires

 

01/02 2017

v1.0.1

1.0.1.0

FlowQuery groupBy operation to group arrays by EEL discriminator

  Sources   Download

GPL-3.0+

The Requires

 

01/02 2017

v1.0.0.x-dev

1.0.0.9999999-dev

FlowQuery groupBy operation to group arrays by EEL discriminator

  Sources   Download

GPL-3.0+

The Requires

 

27/09 2016

v1.0

1.0.0.0

FlowQuery groupBy operation to group arrays by EEL discriminator

  Sources   Download

GPL-3.0+

The Requires