Problem/Motivation

I've added various fields to my menu. Some text, some links, some paragraphs. Save and clear cache. The menu items show up, but none of the added fields.

Steps to reproduce

Add fields. Clear Cache. Refresh page, no added fields.
I've tried switching themes to use Core themes. I've turned on the Demos module and the Body and Term fields it uses, show up. But no new fields I add are rendered.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

    Support from Acquia helps fund testing for Drupal Acquia logo

    Comments

    StevenPatz created an issue. See original summary.

    munish.kumar’s picture

    Hi @StevenPatz,

    I have tried to reproduce this issue with one of the drupal core theme, but not able to reproduce. I have added some custom fields to menu and add some data. Menu item will render properly with custom fields data. I have added the screenshot in which I have added the custom link field in the menu item and add some link in it. The custom link also render with the menu item.

    Thanks,
    Munish

    munish.kumar’s picture

    Status: Active » Needs review
    StevenPatz’s picture

    Status: Needs review » Active

    Looking for some additional help. if I use a theme such as bartik, I can add and see extra fields like you'd expect. But with our custom theme, even with all .theme preprocess hooks disabled, all I can get displayed is the actual menu items. There doesn't seem to be any CSS hiding anything, as the HTML just doesn't have anything in it. Example my theme:

     <ul class="primary-nav usa-accordion" role="navigation" aria-label="Primary">
        
                <li class=" has-submenu ">
    
                
                    <a class="accordion-button nav-link" aria-expanded="false" tabindex="0" aria-controls="megamenu-1">
                        <span>
                            Link of Level One
                            <span class="nav-arrow"></span>
                        </span>
                    </a>
                      
      
                <ul id="megamenu-1" class="nav-submenu">
    
            
        
                <li class="">
    
                                                    <a href="http://example.com" >
                                            <span>Link of Level Two</span>
                        </a>
                                        </li>
            </ul>
      

    Example bartik:

    <ul class="menu menu-level-0">
      
        <li class="menu-item menu-item--expanded">
          <a href="http://example.com" title="Sample Description">Link of Level One</a>
    
    
    <div class="menu-item-teaser">
      <h2>Link of Level One</h2>
      
    
                <div class="field field--name-field-image field--type-image field--label-hidden field__item">
    
    <img src="/sites/default/files/2020-10/test_iamge.jpg" width="583" height="524" alt="" typeof="foaf:Image" />
    
    </div>
          
    
    
                <div class="clearfix text-formatted field field--name-field-body field--type-text-long field--label-hidden field__item"><p>Link of Level One Body Value</p></div>
          
    <!-- END OUTPUT from 'core/themes/bartik/templates/classy/field/field--text-long.html.twig' -->
    
    
      <a href="http://example.com">Go to Link of Level One</a>
    </div>
    
    </ul>
    

    The img tag in the second example is one of the extra fields. What could be stopping the module from actually generating and populating variables for the theme to display? The Demo seems to work fine in bartik, terms, images, body fields all show up. None of these do in our custom theme.

    StevenPatz’s picture

    As a further followup. If I place some HTML comments into menu-link-content.html.twig and menu-levels.html in the contrib templates directory, I see those comments on Bartik, but none of the comments in my custom theme. It seems the twig isn't getting loaded in the custom, but I can't track down why that would be. Any ideas, appreciated.

    fmitchell’s picture

    I'm also experiencing the same issue on a custom theme. Switching to Bartik renders the menu items fine. @StevenPatz, were you able to figure out anything?

    StevenPatz’s picture

    Unfortunately, no. We had to find another module to replicate what we wanted to do with this module.

    FatherShawn’s picture

    Installed in a fresh D10.1 site, I do not see the added fields in Olivero but switching to Stark and they render. Looking deeper, Stark uses menu--extras.html.twig but Olivero is choosing menu--primary-menu.html.twig which I'm sure is a theme template taking priority over a module template.