Auto Hide Navigation Items if Collection is Empty - Symmetry Theme

Hello, I am working with the Symmetry Theme ‘header.liquid’ file and trying to auto hide navigation links that link to an empty collection. My problem is, when trying to target the inner tiers of the navigation, I end up being able to auto hide only the first tier of the nav. The code example below is what I have written at 3 different points of the ‘header.liquid’ file. The navigation itself is split into 3 tiers each being more specific from the last. An example would be ‘Trading Card Games < Pokemon < Booster Packs’. I am able to hide the entire ‘Trading Card Games’ section if its children collections are empty, but I am not able to hide the ‘Pokemon’ or ‘Booster Packs’ sections individually.

{% unless link.type == ‘collection_link’ and link.object.products_count == 0 %}

  • {% endunless %}

    Any help with this would be much appreciated. I am very new to liquid so if you need more information please ask.

    I managed to find the solution for anyone looking in the symmetry theme. The original code was:

    {% unless link.type == ‘collection_link’ and link.object.products_count == 0 %}

  • {% endunless %}

    The revised code is:

    {% unless child_child_link.type == ‘collection_link’ and child_child_link.object.products_count == 0 %}

  • {{ child_child_link.title }}
  • {% endunless %}

    The code to change can be found in the ‘header.liquid’ file of the symmetry theme. The key here is to target the children’s children in the liquid file using ‘child_child_link.type’ instead of ‘link.type’.