Score:-1

anchor menu description under each menu in menu.html.twig

br flag

I am currently displaying the Menu "description" underneath each link using menu.html.twig. by doing this:

{% if item.original_link.getDescription %}
  <span class="navigation__link-description">{{ item.original_link.getDescription() }}</span>
{% endif %}

The issue is that it's not anchored with the URL due to it being outside {{ link(item.title, item.url) }}. Does anyone know what I need to do?

Here's a small snippet of where my description is:

        {% if menu_attributes.link is empty %}
          {{ link(item.title, item.url) }}
          {% if item.original_link.getDescription %}
            <span class="navigation__link-description">{{ item.original_link.getDescription() }}</span>
          {% endif %}
        {% else %}
          {{ link(item.title, item.url, menu_attributes.link) }}
        {% endif %}
        {% if item.below %}
          {{ menus.menu_links(item.below, attributes, menu_level + 1) }}
        {% endif %}
      </li>
    
Score:-1
in flag
{% if item.original_link.getDescription %} 
  <span class="navigation__link-description">
    {{ link(item.original_link.getDescription(), item.url, menu_attributes.link) }}
  </span>
{% endif %}

Try the above to create another link using your descriptipion as text. If we need link then link() function should be used.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.