XF 2.2 How can I show reactions in a widget?

rhodes

Active member
Hello,

In addition to the standard “Like” button I have defined additional reactions in my forum, e.g. “love”, “amazing” and “helpful info”. My users love it and make extensive use of it.

Now I was wondering if and how I can retrieve, for example, 10 posts that have been rated “amazing” at least three times in a widget.

Can I access reactions in my widget callback with the XF Finder or with the Xenforo API, or would it make more sense to query the database tables directly with SELECT?

I am grateful for any tips.
 
Hiya, I was looking into reactions recently and I found this in the post_macros template
HTML:
<div class="reactionsBar js-reactionsList {{ $post.reactions ? 'is-active' : '' }}">
    <xf:reactions content="{$post}" link="posts/reactions" />
</div>

Not sure how this tag so you'd need to look into it yourself.
Also check out the template reactions_summary it shows how to display a single reaction I think.

After checking out the Templater options, the tag <xf:reaction> can have these parameters in 2.3.7:
Code:
    $baseConfig = [
            'id' => null,
            'class' => '',
            'content' => null,
            'link' => '',
            'params' => [],
            'list' => null,
            'hasreaction' => false,
            'init' => false,
            'showtitle' => false,
            'appendtitle' => '',
            'small' => false,
            'medium' => false,
            'tooltip' => false,
            'routerType' => 'public',
        ];
 
Last edited:
Back
Top Bottom