×
1 Choose EITC/EITCA Certificates
2 Learn and take online exams
3 Get your IT skills certified

Confirm your IT skills and competencies under the European IT Certification framework from anywhere in the world fully online.

EITCA Academy

Digital skills attestation standard by the European IT Certification Institute aiming to support Digital Society development

SIGN IN YOUR ACCOUNT TO HAVE ACCESS TO DIFFERENT FEATURES

CREATE AN ACCOUNT FORGOT YOUR PASSWORD?

FORGOT YOUR DETAILS?

AAH, WAIT, I REMEMBER NOW!

CREATE ACCOUNT

ALREADY HAVE AN ACCOUNT?
EUROPEAN INFORMATION TECHNOLOGIES CERTIFICATION ACADEMY - ATTESTING YOUR PROFESSIONAL DIGITAL SKILLS
  • SIGN UP
  • LOGIN
  • SUPPORT

EITCA Academy

EITCA Academy

The European Information Technologies Certification Institute - EITCI ASBL

Certification Provider

EITCI Institute ASBL

Brussels, European Union

Governing European IT Certification (EITC) framework in support of the IT professionalism and Digital Society

  • CERTIFICATES
    • EITCA ACADEMIES
      • EITCA ACADEMIES CATALOGUE<
      • EITCA/CG COMPUTER GRAPHICS
      • EITCA/IS INFORMATION SECURITY
      • EITCA/BI BUSINESS INFORMATION
      • EITCA/KC KEY COMPETENCIES
      • EITCA/EG E-GOVERNMENT
      • EITCA/WD WEB DEVELOPMENT
      • EITCA/AI ARTIFICIAL INTELLIGENCE
    • EITC CERTIFICATES
      • EITC CERTIFICATES CATALOGUE<
      • COMPUTER GRAPHICS CERTIFICATES
      • WEB DESIGN CERTIFICATES
      • 3D DESIGN CERTIFICATES
      • OFFICE IT CERTIFICATES
      • BITCOIN BLOCKCHAIN CERTIFICATE
      • WORDPRESS CERTIFICATE
      • CLOUD PLATFORM CERTIFICATENEW
    • EITC CERTIFICATES
      • INTERNET CERTIFICATES
      • CRYPTOGRAPHY CERTIFICATES
      • BUSINESS IT CERTIFICATES
      • TELEWORK CERTIFICATES
      • PROGRAMMING CERTIFICATES
      • DIGITAL PORTRAIT CERTIFICATE
      • WEB DEVELOPMENT CERTIFICATES
      • DEEP LEARNING CERTIFICATESNEW
    • CERTIFICATES FOR
      • EU PUBLIC ADMINISTRATION
      • TEACHERS AND EDUCATORS
      • IT SECURITY PROFESSIONALS
      • GRAPHICS DESIGNERS & ARTISTS
      • BUSINESSMEN AND MANAGERS
      • BLOCKCHAIN DEVELOPERS
      • WEB DEVELOPERS
      • CLOUD AI EXPERTSNEW
  • FEATURED
  • SUBSIDY
  • HOW IT WORKS
  •   IT ID
  • ABOUT
  • CONTACT
  • MY ORDER
    Your current order is empty.
EITCIINSTITUTE
CERTIFIED

How can you configure a filter in Webflow CMS to exclude the current blog post from appearing in a list of featured posts on a blog collection page?

by EITCA Academy / Monday, 19 August 2024 / Published in Web Development, EITC/WD/WFCE Webflow CMS and eCommerce, Advanced dynamic content, Filter Collection lists, Examination review

To configure a filter in Webflow CMS to exclude the current blog post from appearing in a list of featured posts on a blog collection page, one must understand the intricacies of Webflow's dynamic content capabilities, particularly the filtering mechanisms available within the CMS. This task requires a combination of setting up the CMS Collection, using Webflow's filtering options, and applying conditional visibility settings. Here is a detailed explanation of the process:

Step-by-Step Guide to Exclude the Current Blog Post

1. Set Up CMS Collections:
– Ensure that you have a CMS Collection set up for your blog posts. Each blog post should have fields such as Title, Slug, Body, Featured Image, and any other necessary metadata.

2. Create a Collection List:
– On your blog collection page, add a Collection List element. This will be used to display your featured posts.
– Bind this Collection List to your Blog Posts Collection.

3. Filter the Collection List:
– To exclude the current blog post, you need to set up a filter on the Collection List.
– Click on the Collection List element to open the settings panel.
– In the settings panel, find the Filter option and click on it to add a new filter.

4. Exclude the Current Post:
– Add a filter condition that excludes the current post. This can be done by setting a filter where the Blog Post slug is not equal to the current blog post slug.
– Since Webflow does not directly allow filtering by the current page's slug, you need to use a workaround involving custom code.

Implementing Custom Code

To achieve the exclusion of the current blog post using custom code, follow these steps:

1. Add a Custom Attribute:
– First, add a custom attribute to the Collection List Wrapper. This custom attribute will help in identifying the current post.
– Select the Collection List Wrapper and go to the settings panel.
– Add a custom attribute, for example, `data-current-post`, and set its value to the current post's slug.

2. Embed Custom Code:
– You will need to use JavaScript to dynamically filter out the current post.
– Add an Embed element to your page, preferably within the Collection List Wrapper.
– Insert the following JavaScript code within the Embed element:

html
<script>
  document.addEventListener('DOMContentLoaded', function() {
    // Get the current post slug from the custom attribute
    var currentPostSlug = document.querySelector('[data-current-post]').getAttribute('data-current-post');
    
    // Select all items in the Collection List
    var collectionItems = document.querySelectorAll('.w-dyn-item');

    // Loop through each item and hide the one that matches the current post slug
    collectionItems.forEach(function(item) {
      var itemSlug = item.querySelector('.slug-class').textContent.trim(); // Assuming you have a class to get the slug
      if (itemSlug === currentPostSlug) {
        item.style.display = 'none';
      }
    });
  });
</script>

Explanation of the Custom Code

– Event Listener: The code waits for the DOM content to load completely before executing.
– Get Current Post Slug: It retrieves the current post's slug from the custom attribute (`data-current-post`) set on the Collection List Wrapper.
– Select Collection Items: It selects all items within the Collection List using the class `.w-dyn-item`.
– Loop and Compare: It loops through each item, retrieves the item's slug, and compares it with the current post's slug. If they match, the item is hidden by setting its display style to 'none'.

Ensuring Proper Slug Retrieval

For the JavaScript code to work correctly, ensure that each blog post item within the Collection List has an element containing the slug. This can be a hidden element or a data attribute. For example:

html
<div class="w-dyn-item">
  <div class="slug-class" style="display: none;">{{slug}}</div>
  <!-- Other blog post content -->
</div>

Additional Considerations

– SEO Implications: Ensure that hiding elements using JavaScript does not negatively impact your SEO. Search engines might still index hidden content.
– Performance: While the JavaScript approach is effective, it runs on the client side. For large collections, this might impact performance. Always test the performance impact on your specific setup.
– Webflow Limitations: Webflow's native filtering options do not currently support dynamic exclusions based on the current page context. The custom code approach is a workaround until such features are potentially added in future updates.

Example Scenario

Imagine you have a blog post with the slug `how-to-use-webflow`. When a user visits this blog post page, you want to display a list of featured posts but exclude `how-to-use-webflow` from this list. By following the steps and implementing the custom code, your Collection List will dynamically hide the current post, ensuring that only other featured posts are displayed to the user.

This method leverages Webflow's flexibility and the power of custom code to achieve a more dynamic and user-friendly blog experience. By understanding and applying these techniques, you can enhance the functionality and interactivity of your Webflow CMS projects.

Other recent questions and answers regarding Advanced dynamic content:

  • How does conditional visibility contribute to creating more sophisticated and user-friendly web experiences in Webflow?
  • In what way can a static text link be utilized as an alternative contact method when a team member does not have an email set, and how would you configure its conditional visibility?
  • How can conditional visibility be used to manage the display of an email link for team members in a collection list, ensuring it only appears when an email is set?
  • What steps would you take to configure a section element to display only when the "Work Category" is set to "Portraits" on a collection page in Webflow?
  • How does conditional visibility enhance user experience in Webflow CMS and eCommerce by displaying only relevant information on a webpage?
  • How can filters be used to dynamically update a collection list to reflect changes or new items added to a collection in Webflow CMS?
  • What role do reference fields play in managing content categories within Webflow CMS, and how can filters be applied to display posts matching the current category?
  • What is the process for creating a switch field labeled "Featured" within a collection, and how does it affect the display of collection items?
  • How can filters in Webflow CMS enhance the user experience when managing dynamic content?

More questions and answers:

  • Field: Web Development
  • Programme: EITC/WD/WFCE Webflow CMS and eCommerce (go to the certification programme)
  • Lesson: Advanced dynamic content (go to related lesson)
  • Topic: Filter Collection lists (go to related topic)
  • Examination review
Tagged under: CMS, Custom Code, Dynamic Content, JavaScript, Web Development, Webflow
Home » Advanced dynamic content / EITC/WD/WFCE Webflow CMS and eCommerce / Examination review / Filter Collection lists / Web Development » How can you configure a filter in Webflow CMS to exclude the current blog post from appearing in a list of featured posts on a blog collection page?

Certification Center

USER MENU

  • My Account

CERTIFICATE CATEGORY

  • EITC Certification (106)
  • EITCA Certification (9)

What are you looking for?

  • Introduction
  • How it works?
  • EITCA Academies
  • EITCI DSJC Subsidy
  • Full EITC catalogue
  • Your order
  • Featured
  •   IT ID
  • EITCA reviews (Reddit publ.)
  • About
  • Contact
  • Cookie Policy (EU)

EITCA Academy is a part of the European IT Certification framework

The European IT Certification framework has been established in 2008 as a Europe based and vendor independent standard in widely accessible online certification of digital skills and competencies in many areas of professional digital specializations. The EITC framework is governed by the European IT Certification Institute (EITCI), a non-profit certification authority supporting information society growth and bridging the digital skills gap in the EU.

    EITCA Academy Secretary Office

    European IT Certification Institute ASBL
    Brussels, Belgium, European Union

    EITC / EITCA Certification Framework Operator
    Governing European IT Certification Standard
    Access contact form or call +32 25887351

    Follow EITCI on Twitter
    Visit EITCA Academy on Facebook
    Engage with EITCA Academy on LinkedIn
    Check out EITCI and EITCA videos on YouTube

    Funded by the European Union

    Funded by the European Regional Development Fund (ERDF) and the European Social Fund (ESF), governed by the EITCI Institute since 2008

    Information Security Policy | DSRRM and GDPR Policy | Data Protection Policy | Record of Processing Activities | HSE Policy | Anti-Corruption Policy | Modern Slavery Policy

    Automatically translate to your language

    Terms and Conditions | Privacy Policy
    Follow @EITCI
    EITCA Academy

    Your browser doesn't support the HTML5 CANVAS tag.

    • Cloud Computing
    • Cybersecurity
    • Web Development
    • Quantum Information
    • Artificial Intelligence
    • GET SOCIAL
    EITCA Academy


    © 2008-2026  European IT Certification Institute
    Brussels, Belgium, European Union

    TOP
    CHAT WITH SUPPORT
    Do you have any questions?
    We will reply here and by email. Your conversation is tracked with a support token.