Forum
Using tags as a "Favourite" feature
I'm wondering if it's possible to use member tags as a way to allow members to "favourite" content.
Could members set their own tags by clicking a link on a page?
I'm wondering if it's possible to use member tags as a way to allow members to "favourite" content.
Could members set their own tags by clicking a link on a page?
Yes, I don’t see why not.
My idea of the interaction is a grey heart icon which, upon clicking, would set the tag for that member and change the heart red (instagram style). I guess I would need some jquery/ajax magic to make that happen wouldn't I? Any pointers or things to look out for?
You'll want to call
perch_member_add_tag()
https://docs.grabaperch.com/functions/members/perch-member-add-tag/
I would need a page where it outputs all the tags for each member so that they can have a bunch of links to all their favourited content. Is there a perch function for that?
Hello Stephen,
I don't think there is a function in the Members addon that lists tags, but you should be able to work around that.
If members favourite blog posts, for example, you can:
The above is an example using blog posts and assumes the tags you add to the member are blog post slugs. You haven't specified what type of content you're using so you may need to modify the above to make it work for your use case.
Many thanks for this, Hussein.
Currently though the content isn't blog posts or even standard perch pages. The content is created on the fly by the users themselves as it's a classified advert website (think craigslist).
I'm only using perch in this project to make use of the members app (so users can log in and features can be hidden from non members) and the shop app (for upgrading adverts).
Do you think there's still a way around it with this in mind?
It depends on how you've implemented this. I'm assuming you can retrieve a list of all the ads and that each ad has an ID or a slug. If so, you could do something similar to the above.
Yes, the app has a function like this:
Then in the controller I can call it, for example:
If you're building a custom app, you can do whatever your like.
The above solution roughly translates to:
If I were you, I'd write a function that outputs a member's favourite ads to make my life easier:
How you get the favourite ads within the function is up to you. You can query the DB for example.