theme_links without spaces between menu items, great for inline-block

Public

Slightly modified theme_links to rid of spaces between list items to enable inline-block usage on menu items

</> CopyGet raw version
php
  1. function YOURTHEMENAME_links($links, $attributes = array('class' => 'links')) {
  2. global $language;
  3. $output = '';
  4.  
  5. if (count($links) > 0) {
  6. $output = '<ul' . drupal_attributes($attributes) . '>';
  7.  
  8. $num_links = count($links);
  9. $i = 1;
  10.  
  11. foreach ($links as $key => $link) {
  12. $class = $key;
  13.  
  14. // Add first, last and active classes to the list of links to help out themers.
  15. if ($i == 1) {
  16. $class .= ' first';
  17. }
  18. if ($i == $num_links) {
  19. $class .= ' last';
  20. }
  21. if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page())) && (empty($link['language']) || $link['language']->language == $language->language)) {
  22. $class .= ' active';
  23. }
  24. $output .= '<li' . drupal_attributes(array('class' => $class)) . '>';
  25.  
  26. if (isset($link['href'])) {
  27. // Pass in $link as $options, they share the same keys.
  28. $output .= l($link['title'], $link['href'], $link);
  29. }
  30. else if (!empty($link['title'])) {
  31. // Some links are actually not links, but we wrap these in <span> for adding title and class attributes
  32. if (empty($link['html'])) {
  33. $link['title'] = check_plain($link['title']);
  34. }
  35. $span_attributes = '';
  36. if (isset($link['attributes'])) {
  37. $span_attributes = drupal_attributes($link['attributes']);
  38. }
  39. $output .= '<span' . $span_attributes . '>' . $link['title'] . '</span>';
  40. }
  41.  
  42. $i++;
  43. $output .= "</li>"; /* removed "\n" from this line*/
  44. }
  45.  
  46. $output .= '</ul>';
  47. }