Like button

Options
Good day!
"I am a noob" and would like to know the process on the Xano side to 
create a variable for my Like button. So I can connected to Bravo and bind it to my app. If there is any advice or tutorials I would greatly appreciate it

Comments

  • David Richardson
    Options
    While I did this for my site on Webflow, there are aps that do this but maybe not with Xano.  It takes a bit of JavaScript and probably depends on your front end.  I started with this video
    to address the performance issues that arise with a plethora of opportunities to "make a favorite."

    It took ME a while to get it working but start a JavaScript editor and mimic his code.

    If you get that far reach out and I'll share what I did.
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
     you can examine the photo sharing template, which has this functionality. Basically, you want to create a "like" table which references the item being liked and the user_id who is liking it. Creating a like would simply be adding a record to this table. 
  • Michael Udinski
    Michael Udinski Administrator

    ADMIN

    Options
    Here's some content from a recent office hours on this topic:
    
  • Steve Stava
    Options
    I did a two-part series on favoriting a product with Xano and AppGyver. It is about one year old so some things in Xano have changed but I think it applies pretty directly still…

    AppGyver & Xano (Favorites Feature - Part 1): Building a favorites feature for a user's product list
    https://youtu.be/O4GY1xKASL8

    AppGyver & Xano (Favorites Feature - Part 2): Building a favorites feature for a user's product list
    https://youtu.be/Aj1mgSkFgh0
  • Antonio Duenweg
    Options
     Thank you I found this tutorial useful
  • Iulian Maftei
    Options

    @Steve Stava Thank you for this tutorial! May I ask you how can I query the list in order to let the authenticated user to see only his favorite items? (eg. if he has only 2 favorite items, to return only that 2 items).

  • Steve Stava
    Options

    I will give this a shot at a high-level. I don't have the project in Xano anymore so I can't test what I am offering here :)

    1. Do a query all records against the list of favorites (the xref table of user & product). Filter on the auth.id that is available on authenticated APIs. That will give you a list of all of that user's favorited products.
    2. Add a Join to that same query all records. Join to the product table so you can get the product information that you will most likely want to display in your UI. To have that info show up in the response of the query you need to do a couple of things.
      1. Go to the Output tab in the query function you just built. Go all the way to the bottom and select "Evals" and then add an item ("+"). In the drop down you will see the list of fields for the two tables you have Joined. Pick the fields from the Product table that you want returned in the query
      2. Now, go to the Customize button on the Output tab and make sure that the new fields you selected in Evals are selected in Customize so they get returned with the query results

    I think this should get you there. Let me know what happens! (Thanks for watching my videos!!)

  • Iulian Maftei
    Options

    Thanks a lot, @Steve Stava !

    I just tried your suggestion and everything looks good until I add the Evals. After I add the evals the query filter db:likes.users_id == auth:id is ignored and the entire list is returned again. Any idea why?

    After I add the evals tradespeople.name as tradespeople_name

  • Steve Stava
    Options

    I don’t think I mentioned in my comment to have a filter in your join clause that specifies to match on trades people ID from the trade people table to be equal to the trade people ID from the favorites table that was selected

  • Iulian Maftei
    Options

    @Steve Stava Absolute legend! Many many thanks! It works great.

  • Steve Stava
    Options

    I am happy I could help. Enjoy the rest of your build!