A collection in liara groups content together into an optionally ordered collection. This grouping is efficient, i.e. iterating a sorted collection does not incur any sorting cost. It is also efficient to look up the next/previous entry in an collection.
A collection definition consists of three elements:
The filter – this is an URL pattern which defines all elements that are in this collection.
The ordering – optionally specifies how the collection should be ordered. This is a metadata accessor, to access nested fields, separate the individual accesses using
.. For instance,
date.yearwill access the
datemetadata field first, and then the
yearattribute. If you want to reverse the order, add a leading
-, for example
blog: filter: '/blog/**' order_by: 'date'
Defines a collection named
blog, which contains all elements under
/blog, ordered by the
date metadata field.
Collections can be obtained from the
Site object using
get_collection(). If ordered,
get_previous_in_collection() can be used to provide next/previous links. The other use of collections are Indices.