- last update
14 days ago Composer require failure - πΊπΈUnited States Zevarix Phoenix, Arizona
Rerolled patch from comment 15 to work with menu block 8.x.1-11
- last update
14 days ago 11 pass
On my site I use a taxonomy vocabulary to give each department its own space. On each department's site, I want the navigation menu to show only the current department's content, not content belonging to other departments.
I'm using Taxonomy Menu to generate a menu based on the Departments taxonomy and I want to use Menu Block to add the menu to the pages. However, Menu Block doesn't currently provide a way to filter out unrelated content and taxonomy.
Two caveats:
Here are a couple visual examples of how the navigation menu should work.
Example 1:
Expected result:
Example 2:
Expected result:
After spending a few days experimenting with it, I've created a working solution. It appears to support as many menu levels as might be needed, and to the best of my knowledge doesn't contain any hacks and is compliant with Drupal's coding style guide.
All that said, I don't consider myself a backend developer. I spend most of my time as frontend developer, and as such I'm certainly not as familiar with Drupal's backend as many of the members of this community. If anyone sees any issues with this solution or sees a way that it could be done better, please let me know and I'm more than happy to either rework it myself, work together to fix it, or let someone else do it.
Note: My solution started out using the accepted solution posted at https://drupal.stackexchange.com/questions/183201/get-menu-link-siblings as a reference, but I simplified it.
Adds a checkbox under Advanced Options in the menu's block configuration labeled "Show current taxonomy term content and active taxonomy hierarchy."
Adds (in src/Plugin/Block/MenuBlock.php):
Adds a new Boolean configuration setting called show_current_term_content to store the setting for this option.
Needs review
1.11
Code
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
Rerolled patch from comment 15 to work with menu block 8.x.1-11