At DrupalCampNYC I saw that 5.0 allows really cool login/logout menu items that recognize whether a user is logged in or not and displays the appropriate setting accordingly. I would love to have this, but I'm not that good at PHP and I need to keep 4.7.x for the gmap and location modules.
Can anyone provide a solution? What I want in particular is a primary link that says "login" and links to the login page when the user is anonymous, but says "logout" when the user is authenticated.
I thought a good solution was to have certain menu items appear according to PHP rules, but as far as I can tell, I can only apply PHP rules to menu blocks, not to the items within those menu blocks. Please help.
Comments
The logout menu item can
The logout menu item can easily be placed in the primary links. This will only show to authenticated users, thus it will only show when a user is indeed logged in. Adminster -> Menus -> logout -> edit
As far as getting the login up there and making is disappear after a user is logged in, I have no idea.
Yeah, I discovered that
Yeah, I discovered that logout does exactly that. Wonderful!
Does anyone else know why login can't be made to do the same thing? How can I elegantly provide a link to a login page without using the login block or having the link stick around once people need not login anymore?
In your page.tpl.php or
In your page.tpl.php or wherever it is that you are placing the link, surround it in something like this:
That will only display the link if the individual viewing the page hasn't logged in.
---
www.whatwoulddrupaldo.org
I don't really know PHP, but
I don't really know PHP, but that didn't work for me.
This, however, did:
Ah, yeah, I meant
Ah, yeah, I meant
Glad you got it working.
---
www.whatwoulddrupaldo.org
Thanks for your help! I
Thanks for your help! I changed it back to what you meant, since it seems cleaner than what the monkeys in my basement happened to type out on their keyboards for me.
Login Menu module
There's a discussion going on about this at http://drupal.org/node/120197