My Drupal site has more than 20 links on the main navigation and I would like the sequence of those links to alphabetize in reverse order... Z to A. My links have dates in them and I'm using this format which appears as the first characters in the link:
2006-11-15
2006-12-20
2007-01-31

The newest data should be on top, however, that has the lowest alphabetized name: "2007" is lower than "2006".

Is this possible?

Many thanks!

Comments

Anonymous’s picture

I ran into this the other day when my tabs were in reverse order from my menu, and solved it with a little php.

Menus are just arrays of links, so using array_reverse() command in PHP it will reverse the ordering.

If you are using Primary Links menu, you would open up the page.tpl.php file and change the primary links display to something like this:

print theme('menu_links', array_reverse($primary_links))

---

If its a standard menu you can adjust the "weight" of each menu item so its reversed.

---

OR override the "menu_links" theme... a bit more complicated, and would change the output for all menus, not likely what you want.

-G

Lyal’s picture

In regards to doing it within its own theme (which is recommended):

First, add an entry for theme_menu_tree
in your template.php as outlined on http://drupal.org/node/11811 .

Within this function (or an included file), check to see which menu you're theming. If it's the one you're shooting for, do the array reversal, and return the results. Otherwise, use the normal theme code.

function theme_menu_tree($tree) {
  return '<ul class="menu">'. $tree .'</ul>';
} 

Outcome3 Drupal Services
Vancouver Technology Guy

zanematthew’s picture

i do NOT want my primary links alphabetized, I want them in the order they are created using drupal site builder is this possible?
what youl I have to override to do this?