0

here's my current twig template menu-levels.html.twig as I've hooked

preprocess_menu_levels(&$variables) {$variables['display']='mobile';}

=> I get display variable in the first parent twig file, which works well

{#  menu-levels.html.twig  #}
{% set display = 'mobile' %}
{# was basically injected above #}
<li{{ item.attributes.addClass(menu_item_classes) }}>
    {{ link(item.title, item.url) }}
    {% set rendered_content = item.content|without('') %}
    {% if rendered_content|render %}
    {# is menu-link-content.html.twig => does not herit from var#}        
        {{ rendered_content }}
    {% endif %}
</li>

My problem is : how can I achieve accessing to this variable into menu-levels.html.twig ? ( the tyig template used for rendering the item.content )

Thanks a lot for anz enlightment, clue, notice, comment ;)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.