Drupal站点nice-menus子菜单节点标题缺失问题求助
Hey there, let's dig into this frustrating issue you're facing—super weird that your submenu items still work (hrefs are intact) but lost all their visible title/content, especially since things ran smoothly for years. Here are the most actionable fixes I've seen for this exact scenario:
1. Double Down on Cache Clearing (Yes, Even If You Did This Already)
Drupal's cache can hold stale render data that sticks around even after a quick UI clear. Try a deeper cache rebuild via Drush first—this often fixes odd rendering glitches:
# For Drupal 8+ drush cache:rebuild # For older Drupal versions drush cc all
Don't forget to clear any reverse proxy (like Varnish) or CDN caches too—they might be serving old menu HTML that doesn't reflect the current state of your site.
2. Check for Corrupted Nice-Menus Template Overrides
If your theme uses a custom template for nice-menus (like nice-menus-default.tpl.php or nice-menus-primary.tpl.php), it could have been accidentally modified or corrupted:
- Compare your theme's template file with the original from the nice-menus module. Look for lines that print the menu item text—like
<?php print $link; ?>or<?php print $item['title']; ?>. If those lines are commented out or deleted, that's your culprit. - If you don't need the custom override anymore, just delete it and let the module use its default template.
3. Verify Menu Item Permissions & Status
Oddly enough, permission changes can cause menu items to render without text (even if the underlying link still works):
- Head to
Structure > Menus > Primary links(admin/structure/menu/manage/primary-links) - Check each submenu item: Make sure they're set to Enabled, and confirm that the
View published contentpermission is granted to the user roles that should see the menu (anonymous/authenticated). - Also, look for items using a custom access callback—if that callback is broken, it might suppress the title while leaving the link intact. Try disabling the custom access temporarily to test.
4. Rule Out Module Conflicts
A recent module update (either nice-menus itself, a menu-related module like Menu Attributes, or even a core Drupal update) could be causing a conflict:
- Disable non-core modules one by one, clearing cache after each, to see if the submenu text comes back. Start with modules that touch menu rendering or theming.
- If you spot the conflicting module, roll it back to a previous version that worked, or check its issue queue for similar reports.
- Double-check that your nice-menus version is fully compatible with your current Drupal core version—core updates often require matching module updates.
5. Inspect HTML & CSS (Text Might Be Hidden, Not Missing)
Sometimes the text is actually present in the code but hidden by CSS:
- Right-click an empty submenu item and select "Inspect" (Chrome/Firefox). Look at the HTML—you should see something like
<a href="/path">Menu Title</a>. If the text is there but not visible, check your CSS for:text-indent: -9999px(common for image replacement, but sometimes applied accidentally to submenus)color: transparentoropacity: 0overflow: hiddenpaired with a fixed height that cuts off the text
- Adjust or remove those CSS rules if they're targeting nice-menus subitems.
6. Check for Database Corruption (Last Resort)
In rare cases, menu item titles might have gone missing from the database:
- Run a database repair (use your hosting provider's tool or
drush sql:repairif available) - Check the
menu_linkstable directly—look at thelink_titlecolumn for your submenu items. If the value is empty, restore it from a backup or re-enter the title via the menu UI.
Most of the time, this issue gets fixed by clearing caches properly, fixing a corrupted template, or resolving a module conflict. Start with the simplest steps first—they're the most common culprits.
内容的提问来源于stack exchange,提问作者jiraiya

