Welcome back! In this tutorial, we'll continue our exploration of the powerful integration between Webflow, Memberstack, and Xano. If you haven't already, I highly recommend watching Part 1 where we covered setting up the foundation and listing items based on membership.
Now, let's take it a step further by creating a single item view, allowing users to favorite items and add comments. Buckle up, because we're about to unlock some really cool functionality!
First, let's create a new page in Webflow called "item". This will be the destination when a user clicks on an individual item from the list view.
// Get the item ID from the URL
let myURL = new URL(window.location.href);
let id = myURL.searchParams.get("id") || "1";
// API endpoint to fetch a single item
const itemUrl = "https://YOUR_XANO_API_ENDPOINT/items/" + id;
// Function to fetch and display the item
function getItem() {
const xhr = new XMLHttpRequest();
xhr.open("GET", itemUrl);
xhr.onload = function () {
if (xhr.status === 200) {
const data = JSON.parse(xhr.responseText);
const itemContainer = document.getElementById("itemContainer");
const card = itemContainer.getElementsByClassName("sample-card")[0];
card.getElementsByTagName("img")[0].src = data.banner;
card.getElementsByTagName("h3")[0].textContent = data.name;
card.getElementsByTagName("p")[0].textContent = data.description;
}
};
xhr.send();
}
// Call the getItem function after a short delay
setTimeout(getItem, 250);
This JavaScript fetches the item details from the Xano API based on the item ID in the URL. It then populates the sample card with the item's banner image, name, and description.
YOUR_XANO_API_ENDPOINT in the JavaScript with your actual Xano API endpoint URL.Now, let's enable users to favorite items. We'll create a "Mark as Favorite" button that submits a form to Xano, storing the favorited item.
itemId (passes the current item ID)formType (differentiates between form types, e.g., "favorite")webflowMemberId (passes the user's Webflow member ID)<input type="hidden" name="itemId" data-name="Item ID" value="{{item.id}}">
<input type="hidden" name="formType" data-name="Form Type" value="favorite">
<input type="hidden" name="webflowMemberId" data-name="Webflow Member ID" value="{% static_member_info 'id' %}">
webhook.site to inspect the payload sent by Webflow.webflowMemberId from the payload.webhook.site URL with your Xano API endpoint URL in Webflow's webhook settings.Finally, let's allow users to leave comments on items. We'll create a comment form and display existing comments from Xano.
itemId, formType, webflowMemberId), but set the formType value to "comment".webflowMemberId from the payload.Congratulations! You've successfully created a single item view with favoriting and commenting functionality, seamlessly integrating Webflow, Memberstack, and Xano. This powerful combination unlocks endless possibilities for building dynamic and feature-rich web applications without writing a single line of code.
Join 100,000+ people already building with Xano.
Start today and scale to millions.
Start building for free