doublesecretagency / craft-upvote

Upvote plugin for Craft CMS
Other
16 stars 6 forks source link

[FR] Get list of users who have liked/upvoted a particular element #25

Closed tom-byrom closed 4 years ago

tom-byrom commented 4 years ago

Hi @lindseydiloreto , Not sure whether this is a feature request or if it's possible out of the box.

Is there any way to return a list of people who have liked/upvoted a particular element?

My use case is so that users can see who liked their entries, this would make it more engaging then just displaying a number.

I know you built the plugin primarily as a voting system but I'm trying to adapt it for more of a social community.

Feeling hopeful

Tom

lindseydiloreto commented 4 years ago

Hi @tom-byrom,

As it currently stands, you'd need to wire up a fair amount of custom Twig or PHP to pull it off. To be clear, it absolutely can be done, but you're going to need a big chunk of custom code to pull it off.

I like the mentality behind it though, I think it's a totally fair feature request. It actually aligns somewhat with a few other issues that have been filed recently (namely #21 and #22). There may be a pull request in the works to address the related issues, but I try not to count my chickens before they hatch. In a perfect world, we could use the momentum from that PR to roll in a FR like this one.

But I can't make any promises at this point. It's a great feature request, but it could potentially sit on the shelf for awhile. I'll leave this thread open until we eventually circle back around to it. 👍

Thanks!

lindseydiloreto commented 4 years ago

Good news, this has been added in Upvote 2.2!

{% set history = craft.upvote.elementHistory(entry.id) %}

... will return something like this...

// User ID : User's Vote
{
     1:  1
    17: -1
    22:  1
    24:  1
}

For a complete explanation, check out the docs on the new elementHistory method...

tom-byrom commented 4 years ago

@lindseydiloreto

That's awesome mate - will check it out later and let you know if I spot anything!