Sorting and Filtering
Often we need to process a collection of ffNodes before outputting it. We might need to filter, sort, group and/or slice them.
For that purpose we can use "ffCollection", which takes a plain array of nodes and provides an API to apply filter- and sorting rules to it. \It also provides a framework to ease the implementation of front-end tools and the persistent storage in back-end to implement filter and sorting interfaces.
getting started
ffCollection is (currently) maintained as a separate plugin, so you need to get hold of it and put it in your plugin directory.
creation of a collection
In the context of a presenter, when we handle arrays of nodes we can replace ffNode::getChildren() with ffNodeCollection::fromParentNode(ffNode $ffNode). [add more use cases for collections, such as carts]
[full reference]
interaction
ffCollection provides some pre-build traits that you can include in your ffListeners for filtering and sorting.
Read Reactive Websites in the Concepts section, if you need to learn more about the concept of callers and listeners and how you can set up an internal API.
file filterListener.php
file sortListener.php
file filterAPI.js
file template.html
persistence
storage takes an optional id/namespace as argument to identify the storage.