Is it possible to access a referenced item's slug in Webflow when building a breadcrumb structure using a subcategory collection?
Published on
September 22, 2023
Yes, it is possible to access a referenced item's slug in Webflow when building a breadcrumb structure using a subcategory collection. However, it requires a specific setup to achieve this.
Here's a step-by-step guide on how to access the referenced item's slug:
- Create a collection for your subcategories:
- Go to the Collections tab in the Webflow Designer.
- Click on "Add Collection" and give it a name (e.g., Subcategories).
- Add a field for the subcategory name and another field for the subcategory's parent (reference field).
- Create a collection template page for your subcategories:
- Go to the Pages tab in the Webflow Designer.
- Click on "Add Page" and select "Collection template".
- Choose the collection you just created (e.g., Subcategories).
- Create a dynamic page for your subcategories:
- Go to the Pages tab in the Webflow Designer.
- Click on "Add Page" and select "Dynamic Page".
- Choose the collection you just created (e.g., Subcategories).
- Set up the breadcrumb structure:
- On your dynamic page template, add a div or container element for your breadcrumb structure.
- Inside the div/container, add a link to the parent category.
- Create a dynamic reference field for the parent category link.
- Select the parent category reference field and choose the appropriate parent category from the dropdown.
- Access the referenced item's slug:
- Add a custom attribute to the link element.
- Name the custom attribute "data-slug".
- Set the value of the custom attribute to the "Slug" field of the referenced collection (e.g., {{parent-category.slug}}).
- Style and format the breadcrumb structure:
- Use CSS to style the breadcrumb structure according to your design preferences.
- You can use margins, paddings, fonts, colors, etc., to achieve the desired look and feel.
By following these steps, you can access a referenced item's slug in Webflow and build a breadcrumb structure using a subcategory collection.
Additional Questions:
- How do I create a collection in Webflow?
- What is a reference field in Webflow collections?
- Can I customize the appearance of the breadcrumb structure in Webflow?