From #1899474: Show entire devel menu rather than just 'Variable editor' I found it impossible to create a text-only item in the admin menu like the following:

<?php
function custom_admin_menu_output_build(&$content) {
 
$content['icon']['icon']['text-only'] = array(
   
'#title' => t('This is a text only link.'),
  );
}
?>

I found that to get it to render properly, I have to use the following which just seems wrong:

<?php
  $content
['icon']['icon']['text-only'] = array(
   
'#title' => t('This is a text only link.'),
   
'#href' => '#',
   
'#options' => array(
     
'external' => TRUE,
    ),
  );
?>

Also, by nature this item doesn't get wrapped in a span either, it's just text inside the li. I have a suspicion that theme_admin_menu_links() should wrap text-only in no matter what in order to be able to style it. The current code related to text-only links is:

<?php
function theme_admin_menu_links($variables) {
    ....
   
// Handle plain text items, but do not interfere with menu additions.
   
elseif (!isset($elements[$path]['#type']) && isset($elements[$path]['#title'])) {
      if (!empty(
$elements[$path]['#options']['html'])) {
       
$title = $elements[$path]['#title'];
      }
      else {
       
$title = check_plain($elements[$path]['#title']);
      }
      if (!empty(
$elements[$path]['#options']['attributes'])) {
       
$link .= '<span' . drupal_attributes($elements[$path]['#options']['attributes']) . '>' . $title . '</span>';
      }
      else {
       
$link .= $title;
      }
    }
    ....
}
?>
Files: 
CommentFileSizeAuthor
#2 admin_menu.span_.2.patch2.35 KBsun
PASSED: [[SimpleTest]]: [MySQL] 228 pass(es).
[ View ]
#1 Selection_027.png15.97 KBDave Reid

Comments

StatusFileSize
new15.97 KB

Screenshot demonstrating what this currently looks like just using #title.

See #1899474: Show entire devel menu rather than just 'Variable editor' for how a text-only item looks when using the workaround.

Status:Active» Needs review
StatusFileSize
new2.35 KB
PASSED: [[SimpleTest]]: [MySQL] 228 pass(es).
[ View ]

OK, how about this? Seems to work for me, but I didn't test extensively.

Status:Needs review» Needs work

The last submitted patch, admin_menu.span_.2.patch, failed testing.

Status:Needs work» Needs review

#2: admin_menu.span_.2.patch queued for re-testing.

Title:Cannot add text-only itemsText-only items are not output correctly
Status:Needs review» Fixed

Thanks for reporting, reviewing, and testing! Committed to all branches.

A new development snapshot will be available within the next 12 hours. This improvement will be available in the next official release.

Status:Fixed» Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.