Hi,

I look for a long time but do not find answer (i use drupal 8).

I would simply want to add a <span></span> in the links of the user menu (like <li><a><span></span></a></li>).

I believe that it is necessary to use preprocess links, but for the moment my tries do not work.

Anybody has the solution?

Comments

Paulset’s picture

It is so complicated?

I looked everywhere, in the api...

It was not useless because I learnt things, but nothing to add how of the markup to a link of menu.

If somebody has some documentation or knows where I have to look, it would be welcome

maikelkoopman’s picture

A solved it in the twig template. I am not sure if it the right way but it works:

{% for item in items %}
  <li{{ item.attributes.addClass('menu__item') }}>
    <a href="{{item.url}}" class="menu__link"> <span class="menu__label"> {{item.title}} </span></a>
   </li>
{% endfor %}