Created
October 17, 2023 00:04
-
-
Save tyssen/fb4ef35da93ebee1f5c8ac1abe388027 to your computer and use it in GitHub Desktop.
Craft categories
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% set props = { | |
categories: props.categories.all() ??? null | |
} %} | |
{% set selectedCategories = props.categories %} | |
{# {% dd selectedCategories %} #} | |
{% set leafCategories = selectedCategories|filter( | |
category => selectedCategories|filter(current => category.isAncestorOf(current)) is empty | |
) %} | |
{# {% dd leafCategories %} #} | |
{% set products = craft.entries.section('products').relatedTo(leafCategories).all() %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment