
Reactions
Universal reactions for MODX 3 — likes, GitHub-style sets, tops and trending on any object


Lists “hot” items with the Reddit hot-ranking formula. Sorted by the trending_score field.
sign = +1 if rating > 0, −1 if rating < 0, 0 if rating = 0
order = log10(max(|rating|, 1))
age = (time_of_last_reaction − epoch) / 45000
trending_score = sign × order + ageFresh items with a high rating rise higher. Epoch is fixed: 1134028003 (27 December 2005).
| Parameter | Default | Description |
|---|---|---|
class | modResource | class_key of objects in the selection |
period | all | Period (trending always uses all) |
limit | 10 | Maximum items |
context | (empty) | Context filter |
tpl | tpl.Reactions.top | Chunk for one list row |
toPlaceholder | (empty) | Placeholder name instead of direct output |
| Placeholder | Description |
|---|---|
[[+idx]] | Row number |
[[+object_id]] | Object ID |
[[+class_key]] | Object class (in the DB: object_class) |
[[+pagetitle]] | Resource title / product name |
[[+uri]] | Object URL (or empty) |
[[+likes]] | Like count |
[[+dislikes]] | Dislike count |
[[+total]] | Sum of all reactions |
[[+rating]] | Rating (likes − dislikes) |
[[+trending_score]] | Trending score (for debug and sorting) |
The period parameter does not narrow the window for trending sort: the score already lives in aggregates (period=all). Pass period only if it keeps the call aligned with TopLiked / TopRated in the same template.
<ul class="reactions-top">
[[!Trending?
&class=`modResource`
&period=`all`
&limit=`5`
]]
</ul><ul class="reactions-top">
{'!Trending' | snippet : [
'class' => 'modResource',
'period' => 'all',
'limit' => 5,
]}
</ul>[[!Trending? &period=`all` &limit=`3`]]{'!Trending' | snippet : ['period' => 'all', 'limit' => 3]}<ul class="reactions-top">
[[!Trending?
&class=`msProduct`
&limit=`6`
]]
</ul><ul class="reactions-top">
{'!Trending' | snippet : [
'class' => 'msProduct',
'limit' => 6,
]}
</ul>[[!Trending?
&limit=`3`
&toPlaceholder=`rx.trend`
]]
<ul class="reactions-top">[[+rx.trend]]</ul>{'!Trending' | snippet : [
'limit' => 3,
'toPlaceholder' => 'rx.trend',
]}
<ul class="reactions-top">{$_modx->getPlaceholder('rx.trend')}</ul><ul class="trending-list">
[[!Trending? &limit=`10` &tpl=`tpl.trending.row`]]
</ul><ul class="trending-list">
{'!Trending' | snippet : [
'limit' => 10,
'tpl' => 'tpl.trending.row',
]}
</ul>web context [[!Trending? &context=`web` &limit=`12`]]Not verified on MODX 3:
[[!Trending? &class=`TicketComment` &limit=`5`]]The trending_score field is recalculated on every reaction (in AggregateService::recount). For a bulk recount:
php core/components/reactions/cli.php recount