Favorite icon and displaying 'Favorite List'

I have been having some difficulty getting a ‘favorite icon’ setup and displaying the ‘favorites’ on a different page.

My app has two different users 1. organization and 2. individual. Each have their own login.

I currently have a page where the individual user can view a list of all organizations in a repeating group (org logo, org name, org address and org type). The individual user can press the ‘view’ button to look at the organization’s full profile and available products (new page, not pop-up).

I want the individual user to be able to ‘Favorite’ the organization (in the org’s profile page) with a heart icon, and then when the individual user goes back to the ‘View all Orgs’ page, there is a heart icon (in the repeating group) that is conditioned to show if the org has been ‘favorited’ or ‘not favorited’. Additionally, I want to display in a number count how many individual users have ‘liked’ the orgs profile.

I am having trouble displaying:

  1. the ‘favorite icon’ state on the ‘view all page’ after the individual user has ‘favorited’ the org profile.
  2. changing the data on the backend (e.g. if a user favorites an org profile, and un-favorites another org profile, how to update the correct org profile and not the ‘last item’ or ‘first item’)
  3. add a count for ‘likes’ (unique to each organization)

I’ve been going in circles for a while, so any help would be greatly appreciated. Thanks!

So, first of all, you need to think about data structure.
You can have a field favourites (type = list of Organisations) in User data type. Or you can have a field favorited-by-user (type = list of Users) in ** Organisations** data type. But keep in mind that lists have a limitation (max 10,000 items in a list) and Bubble reccomends to use lists for relatively small number of items (<100 items).
I suppose your user can potentially favourite 100+ of Organisations and Organisation can have much more than 100 of users who favourite it. If yes - there is another approach to have a separate data type like Favourites with fields user (type = User) and organisation (type = Organisation). So when user adds organisation to favourites - you are creating a new Favourite and populate it with user and organisation.

Again, it depends on your approach. If you don’t need to know exact users that favourited an Organisation and count number is enough - you can just have a field fav-count in your Organisation data type. And just increment or decrement 1 in workflow when user adds/deletes organisation from favourites.

You have a Repeating Group. Each cell = separate Organisation. So if you place an icon in the RG and start the WF to add/delete current cell’s Organisation to favourites - there will been problems.

You can manage it via conditional tab of the checkmark. When current cell’s Organisation is favourited - show icon X. When current cell’s Organisation is not favourited - show icon Y.

Thanks so much for your reply!

I do have a separate data type called Favorites, as I thought this would be the best way to store the information.

Do you recommend having the fav-count as the Favorites data type or the Org Data type ( I have both types setup)?

With the repeating group, is it possible to only display the ‘favorited icon’ when the current user is logged in? This is where I am really stuck.

I think I understand where you are going with this, but I’m still a bit confused.

Sure. Make this icon not visible on page load. And in conditional tab add a condition “when current user is logged in” → visible.

If you only need a number of users that favourited an Organisation (so you don’t need addditional information about which users and when favourited it) - add this field to Organisation data type.

Do you happen to have an example I could follow? Something is not working, and I’m confusing myself with the different data types/users.

Or if you’re interested, I can share with you my test site to take a look at?

I used to have a similar page (adding something to favourites) in my sandbox app but can’t find it. You can share the link to your editor and I’ll take a look.

you need to Settings → General → Applications rights → everyone can view/edit (depending on what power you are going to give us) :slight_smile:
Until it’s done your app is private and nobody can access the editor

This topic was automatically closed after 70 days. New replies are no longer allowed.