verbb / wishlist

A Craft CMS plugin for wishlists for your users to save things to
Other
11 stars 12 forks source link

Following & Followers Lists #135

Closed vonscriptor closed 5 months ago

vonscriptor commented 5 months ago

Question

I'm using Wishlist for users to Follow/Unfollow others. I'd like to show the count (and users) on profiles for Following (count) and Followers (count). Following is straightforward, but how could I query or create a list for Followers?

Additional context

No response

engram-design commented 5 months ago

Are you adding user elements to the wishlists to track users to be able to follow?

If so, you should be able to query based on the item's element, which would be the userId you want to see.

{# Get all items site-wide that have the userId 1234 in them #}
{% set items = craft.wishlist.items().elementId(1234).all() %}

{% for item in items %}
    {# Show the owner of the list #}
    {{ item.list.user }}
{% endfor %}

Does that help?

vonscriptor commented 5 months ago

Very helpful! Thank you!