Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Olivero's book-tree.html.twig includes the following code:
{% if menu_level == 0 %}
<ul{{ attributes.addClass('menu', 'menu--level-' ~ (menu_level + 1)) }}>
{% else %}
<ul class='menu menu--level-' ~ (menu_level + 1)>
{% endif %}
The top-level <ul>
element is fine, but sub-menus are trying to increment menu--level-X classes outside of twig brackets. The code should instead be:
{% if menu_level == 0 %}
<ul{{ attributes.addClass('menu', 'menu--level-' ~ (menu_level + 1)) }}>
{% else %}
<ul class='menu menu--level-{{ menu_level + 1 }}'>
{% endif %}
Comment | File | Size | Author |
---|---|---|---|
#7 | Screenshot 2021-03-23 at 10.29.05.png | 37.32 KB | Gauravvvv |
#7 | Screenshot 2021-03-23 at 10.27.46.png | 38.77 KB | Gauravvvv |
#5 | after-patch.png | 26.95 KB | BhumikaVarshney |
#5 | before-patch.png | 30.32 KB | BhumikaVarshney |
#2 | 3202808_02.patch | 645 bytes | andy-blum |
Comments
Comment #2
andy-blumComment #3
Gauravvvv CreditAttribution: Gauravvvv at OpenSense Labs commentedGood catch @andy-blum, This is the right approach to Adding Level Number Class to Menu Items.
RTBC +1
Comment #4
Madhu kumar CreditAttribution: Madhu kumar as a volunteer and commentedPatch #2 applied cleanly and it is working well to adding Level Number Class to Menu Items.
Comment #5
BhumikaVarshney CreditAttribution: BhumikaVarshney as a volunteer and at OpenSense Labs commentedHi @andy-blum,
Patch in #2 applies cleanly and working fine for me.
Thanks
Comment #6
mherchel+1 RTBC on this.
It looks like this snuck in while massaging this template over from a
{% set %}
statement in menu.html.twig. I verified that this does not occur in any other templates.Great catch and good fix!
Comment #7
Gauravvvv CreditAttribution: Gauravvvv at OpenSense Labs commentedI have attached before and after patch screenshots. Reference to #3.
Comment #10
lauriiiThank you all for looking into this issue.
Posting screenshots of your codebase does not advance the issue, since the automated testing infrastructure tells us whether the patch applies correctly. I've removed the issue credit for the screenshots. In the future, you can get credit for issues by reading the issue to understand its purpose, and posting your review or testing of that purpose. Thank you!
See the issue credit guidelines for more information.
Committed 6ee786e and pushed to 9.2.x and 9.1.x. Thanks!