By cel4145 on
I'm searching for the best way to add a login menu item to the menu system so that I can eliminate the large user login block and merely have it appear in the primary links when the user is anonymous.
Previously, this was easily accomplished in 4.7 as per this recent post through modifying the theme. It looks like now with 5.x that one would have to insert the login link into the $primary_links array, something I don't know how to do. Yet, that other post also mentioned that the login menu item was a feature in 5.x that I haven't been able to find. Anyone have any suggestions? Any links to any code snippets to accomplish this?
Comments
Primary Links
In Drupal 5, the primary Links are set as part of the Menu system (head to /admin/build/menu). There should be a group called "Primary Links" already, although it won't have anything inside it. Just add menu items as you normally would, and hey-presto they'll appear wherever your theme chooses to put them (I'd suggest experimenting with primary links on a core-supplied theme before going ahead and modifying a theme and hoping those primary links show up!).
In fact, some themes have an "Edit Primary Links" link if you're the admin and you're logged in. That takes you right to the Menus admin page. It also gives you a clue where the links will appear when you put them in.
All that said, the login link won't disappear once you're actually logged in if you do it this way. You're going to have to do pretty much the same thing as in the post you linked to. Just make sure the code you put in is outside any "if($primary_links)..." type checks, otherwise your stuff will only show up if you put something in the menus (as above).
Sorry, a slightly verbose and confused response... I hope it helps though!
Almost built-in for Drupal 5
I added a menu item to my Primary Links called "Log in" and linked it to "user/login".
It seems to behave perfectly. It shows up for the anonymous user, but not for an authenticated user. I don't think I did anything special, so it appears to me like this would answer the original question.
Anybody else try this?
I just tried ...
I edited my primary links and added a 'Login' menu item, pointing to "http://mydomain.tld/blog/user/login".
The menu item appeared always, regardless of login status.
Reading your post i changed the pointer to "user/login" and voila: It shows when logged out and disappears when logged in. I don't know why this works, but that's what i need.
Mike
Oh, I forgot: This applies to drupal 5.2
user/login works
user/login and user/register works
should have tried this before
Thanks for info
Login Menu module
Heine wrote a code snippet at http://drupal.org/node/14223#comment-105408 and it was turned into the Login Menu module maintained by rwholheb.
Login Menu Module
Thanks for the link. This is exactly what I need.
-----
Charlie Lowe | cyberdash
Tips for posting to the Drupal forums