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


Lists objects with the highest like counts. Sorted by the likes field in the aggregates table.
| Parameter | Default | Description |
|---|---|---|
class | modResource | class_key of objects in the selection |
period | all | Period: day, week, month, year, all |
limit | 10 | Maximum items |
context | (empty) | Context filter; empty value means all contexts |
tpl | tpl.Reactions.top | Chunk for one list row |
toPlaceholder | (empty) | Placeholder name instead of direct output |
| Placeholder | Description |
|---|---|
[[+idx]] | Row number (1, 2, 3…) |
[[+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 |
| Value | Window |
|---|---|
day | Last 24 hours |
week | Last 7 days |
month | Last 30 days |
year | Last 365 days |
all | All time (from the aggregates table) |
For periods other than all, the component rebuilds the top from raw reaction rows in that window.
Add the <ul class="reactions-top"> wrapper yourself: the row chunk outputs <li>…</li>.
<ul class="reactions-top">
[[!TopLiked?
&class=`modResource`
&period=`week`
&limit=`5`
]]
</ul><ul class="reactions-top">
{'!TopLiked' | snippet : [
'class' => 'modResource',
'period' => 'week',
'limit' => 5,
]}
</ul>day · week · month · year · all Same call, only period changes:
[[!TopLiked? &period=`day` &limit=`5`]]
[[!TopLiked? &period=`month` &limit=`5`]]
[[!TopLiked? &period=`all` &limit=`10`]]{'!TopLiked' | snippet : ['period' => 'day', 'limit' => 5]}
{'!TopLiked' | snippet : ['period' => 'month', 'limit' => 5]}
{'!TopLiked' | snippet : ['period' => 'all', 'limit' => 10]}<ul class="reactions-top">
[[!TopLiked?
&class=`msProduct`
&period=`month`
&limit=`5`
]]
</ul><ul class="reactions-top">
{'!TopLiked' | snippet : [
'class' => 'msProduct',
'period' => 'month',
'limit' => 5,
]}
</ul>Row title and URI come from ObjectLookup / the STI resource; short msProduct is fine.
web context filter [[!TopLiked?
&period=`all`
&context=`web`
&limit=`20`
]]{'!TopLiked' | snippet : [
'period' => 'all',
'context' => 'web',
'limit' => 20,
]}[[!TopLiked?
&period=`all`
&limit=`3`
&toPlaceholder=`rx.top`
]]
<ul class="reactions-top">[[+rx.top]]</ul>{'!TopLiked' | snippet : [
'period' => 'all',
'limit' => 3,
'toPlaceholder' => 'rx.top',
]}
<ul class="reactions-top">{$_modx->getPlaceholder('rx.top')}</ul><ul class="top-liked">
[[!TopLiked?
&period=`week`
&limit=`10`
&tpl=`tpl.top.row`
]]
</ul><ul class="top-liked">
{'!TopLiked' | snippet : [
'period' => 'week',
'limit' => 10,
'tpl' => 'tpl.top.row',
]}
</ul>Not verified on MODX 3:
[[!TopLiked? &class=`TicketComment` &period=`month` &limit=`5`]]