How are menus rendered? When Drupal renders a menu, it shows only those links that the current user has the right to actually click on and visit. Instead of that behavior, I would like to see permissible pages as clickable links and non-permissible pages as non-clickable menu item titles, so that the user can see what they cannot yet click.

I have code that so far loads menu links and creates a list like this, but it doesn't support hierarchy, expanded/collapsed, site-wide menu theming, etc. because all it does is build a &lt;ul> with a &lt;li> item for each menu link title. If you want to look a the code so far, it's Foreshadow Menu (in my Github account). My goal is to render my version of the menu in a way that is consistent with and retains the features of the Drupal-rendered menus.

My question is: how does Drupal render menus? Specifically, how does it determine whether to show/hide a link? Does it use show() and hide() somewhere internally, where I could override and change the menu output? Or am I going about this all wrong?
_menu_tree_check_access() should go a long way towards understanding what Drupal does internally.

It declares a new array of items, then loops through each item currently in the menu and checks access. Only if the current user has the correct access is the item added to the new array. At the end of the function, only the new array is returned. So Drupal's method is actually a bit more low-tech than I think you were going for.

Just so the process is a bit more obvious the functions are called in this order:


menu_build_tree() calls
menu_tree_access() which in turn calls
_menu_tree_access()


If you're looking to emulate the way Drupal builds its menus, I think menu_build_tree() is probably the best place to start.