CMS Library Range Filtering: Step-by-Step Tutorial for Webflow

Published on
August 14, 2020

How to Use the CMS Library for Webflow to Filter by Range

Webflow's CMS library allows users to easily filter content on their websites based on specific criteria. In this tutorial, we will focus on utilizing the CMS library to filter content by range. Whether you're looking to filter products by price range or projects by a specific numerical range, the CMS library makes it easy to implement this functionality on your Webflow site.

What You'll Learn in This Tutorial

  • Setting up project ranges in the CMS library
  • Filtering by project ranges using the CMS library
  • Understanding the data attribute structure and classes needed for custom code
  • Implementing range filtering in the CMS library

Let's dive into the step-by-step process of filtering content by range using the CMS library in Webflow.

Setting Up Project Ranges in the CMS Library

Before we dive into setting up the range filtering functionality, it's important to have a clear understanding of the project ranges we want to filter by. In the CMS library, project ranges can be defined based on specific numerical criteria, such as project numbers, prices, or any other numerical values associated with your projects.

To set up project ranges in the CMS library, follow these steps:

  1. Log in to your Webflow account and access the CMS library section.
  2. Create a new field for projects and define it as a numerical range field. This will allow you to input the range values for each project.
  3. Input the corresponding project ranges for each project in your CMS library. For example, you might have projects labeled as "Project 1: 1.8 to 28.4," "Project 2: 31 to 60," and so on.

By setting up project ranges in the CMS library, you are laying the groundwork for implementing range filtering on your website.

Filtering by Project Ranges Using the CMS Library

Now that we have defined project ranges in the CMS library, we can proceed to implement the range filtering functionality on our website. The CMS library makes it straightforward to filter content based on these defined ranges.

To filter projects by range using the CMS library, follow these steps:

  1. Access the CMS library section and navigate to the filter component.
  2. Create filter buttons for each project range you want to filter by. For example, you might have buttons labeled "1.8 to 28.4," "31 to 60," "61 to 90," and so on.
  3. In the data attribute setup for the filter buttons, specify the name of the data attribute as "range" and set the value to the corresponding project range. For instance, for the "1.8 to 28.4" button, the value would be "1.8 to 28.4."
  4. Ensure that the filter group is correctly applied. In this example, we are using "range filter" as the group class name for our range filtering buttons.

By following these steps, you have successfully set up the filter buttons to operate based on the project ranges defined in the CMS library.

Understanding the Data Attribute Structure and Classes for Custom Code

In order to further customize the range filtering functionality, it's essential to understand the data attribute structure and classes required for custom code implementation. The data attribute setup and class naming play a key role in enabling the CMS library to accurately filter content based on the specified ranges.

Here's a breakdown of the data attribute structure and classes needed for custom code integration:

Data Attribute Setup for Filter Buttons

  • For each filter button, define the data attribute name as "range."
  • Set the value of the data attribute to the specific project range that the button represents. For example, "1.8 to 28.4," "31 to 60," and so on.

Filter Group Class Name

  • Ensure that the filter group has the appropriate class name applied. In the case of range filtering, the class name "range filter" is used to designate the group of buttons responsible for range-based filtering.

Implementing Range Filtering in the CMS Library

With the data attribute structure and classes in place, we are now ready to implement range filtering in the CMS library using custom code. By integrating custom code, we can instruct the CMS library to recognize and filter content based on the specified ranges.

Follow these steps to implement range filtering in the CMS library using custom code:

  1. Access the custom code section in Webflow's designer interface.
  2. Set the "filter range" option to true within the filter groups array for the range filter group. This option signals to the CMS library that the filter group is specifically designated for range-based filtering.
  3. By setting "filter range" to true, the CMS library recognizes the values provided by the range filter buttons as numerical ranges rather than exact matches.

By incorporating these steps, you have successfully configured the CMS library to perform range filtering based on the specified project ranges.

Conclusion

In conclusion, the CMS library in Webflow offers powerful filtering capabilities, allowing you to refine and display content based on specific criteria. By following the steps outlined in this tutorial, you have learned how to set up project ranges in the CMS library, create filter buttons for range-based filtering, understand the data attribute structure and classes for custom code, and implement range filtering using custom code.

Range filtering is a valuable feature for websites that showcase numerical data, such as projects, products, or other categorized content. With the CMS library's range filtering functionality, you can enhance the user experience by enabling visitors to narrow down content based on their specific numerical criteria.

So go ahead and leverage the CMS library's range filtering capabilities to enhance the functionality and user experience of your Webflow site!