Meerkat
A powerful, flat-file comment system for Statamic 4.
Meerkat
A powerful, flat-file comment system for Statamic 4.
Meerkat 2 has tossed away the sorting system from previous versions of Meerkat and replaced it with a new, more powerful system. The syntax for sorting comments is different from previous versions, but the capabilities it unlocks are worth it.
By default Meerkat will sort comments by their id
in descending order (internally, Meerkat comment identifiers are the UNIX timestamp of when they were submitted).
To specify a custom sort order, we can use the orderby
parameter in the {{ meerkat:responses }}
tag:
1{{ meerkat:responses orderby="id,desc" }}2 3{{ comments }}4 <!-- Render the comment thread here. -->5{{ /comments }}6 7{{ /meerkat:responses }}
The syntax for specifying sort order is:
1<PROPERTY_NAME>,<DIRECTION>
The following directions are available:
Variable | Description |
---|---|
asc |
Sorts the property in ascending order (smallest to biggest). |
desc |
Sorts the property in descending order (biggest to smallest). |
The property name and direction are always required.
Multiple sort orders can be applied to a single comment thread by chaining sort orders with the pipe (|
) character. The following example demonstrates how to first sort by newest comments, and then by the contents of the comment:
1{{ meerkat:responses orderby="id,desc|content,asc" }}2 3{{ comments }}4 <!-- Render the comment thread here. -->5{{ /comments }}6 7{{ /meerkat:responses }}
There are many variables that can be used when sorting comment threads; please consult the Default Variables article for information about which properties are available. Compound properties may not be currently supported (i.e., internal_reply_author.name
).
∎
Published on December 7, 2016
Published on April 14, 2018
Published on April 22, 2018