Reactions Work v1.2.6
Add Facebook/linked style reactions to your Craft CMS content
More Craft plugins

API-SDK / The Reactions model

The reactions model contains the data for all submitted reactions to an element or entry.
It specifies how many times a reaction has been voted to, and by whom.


getReaction

For a user and element, returns the reaction a user has previously given to an element.


{% set reactions = reactions_work.reactions(entry) %}
{% set reaction = reactions.reaction(currentUser %}
{# i.e. 'amazed', 'like' or null %}

countReactions / countAllReactions

Counts the reactions for a specific reaction handle, for an element.


{% set reactions = reactions_work.reactions(entry) %}
{{ reactions.countReactions('like') %} likes

{{ reactions.countAllReactions() %} people

getUserIds / getAllUserIds

Returns the user ids of users who voted on an element (last vote first).
For a specific reaction, or for all reactions.


{% set reactions = reactions_work.reactions(entry) %}
{% set userIds = reactions.allUserIds | slice(0,5) %}
{% set users = reactions_work.usersFromIds(UsersIds) %}

{% set userIds = reactions.userIds('wow') | slice(0,5) %}
{% set userIds = reactions.userIds('like') | slice(0,5) %}