New topic Closed topic
avatar image
1
How to check if a record exists within a has/belongs to many setup inside a liquid loop?
By Created , last editted

I'm currently creating a webpage on which a collection of topics is being loaded in. Each of these topics can be bookmarked, on each topic a bookmark button is displayed. When clicked it creates a bookmark record in which the topic and user is being saved. I'm loading in the topics with a liquid FOR loop. How can i check if the bookmark record exists for the user and the topic inside this loop? (I want to add an active class to the bookmark button if the user is already bookmarked)


The setup is like this:

Topic has many Bookmarks

User has many Bookmarks​

Topic --> Bookmark <-- User


Edit: Relations explained


I'm currently creating a webpage on which a collection of topics is being loaded in. Each of these topics can be bookmarked, on each topic a bookmark button is displayed. When clicked it creates a bookmark record in which the topic and user is being saved. I'm loading in the topics with a liquid FOR loop. How can i check if the bookmark record exists for the user and the topic inside this loop? (I want to add an active class to the bookmark button if the user is already bookmarked)


The setup is like this:

Topic has many Bookmarks

User has many Bookmarks​

Topic --> Bookmark <-- User


Edit: Relations explained

Answers
Sort by:

This topic is closed.