By Steve Dondley on
I want to hide the log in block that can be seen by anonymous users and replace it with a less conspicuous link on the navigation menu. Hiding the block was easy. The hard part is figuring out how to make the "log in" menu item disappear when a user is logged in?
Is there anybody out there who has done this and has found an easy solution?
Comments
A small block that disappears after login
You can make a small block that contains the following php code
It takes the user to a page where they can login/register.
Once they login in the block disappears
Thanks
nevet,
Thanks for the input but creating a whole block for one links is more than I want to do. I need it to be a part of the main menu so it blends in more with the rest of the site.
Custom menu
I've been trying to do this too.
I tried making a module which adds some custom menu commands, but if the menu command's path is 'user/login' then it doesn't show up!
I get the impression that there is already a menu item with this path (probably the login tab on the login page), which is in conflict with my code.
Bit of a shame, as it's annoying having to have a custom block for such obviously useful functionality.
Several days ago was posted something similar
Someone could not log in, because he had removed the block. So he was given the link to the "login node" - "www. .... .com/user".
I think you can use it as a "normal" link even in the navigation menu if you have installed the menu.module, which makes it possible to customize the menu itself.
----------
Working on a bilingual mini-portal - www.archeologic.net
cusstom block
There is a built in alias to /user as there is also a built in alias to /admin. These aliases are there for convience as well as funtionality.
More block info here: http://drupal.org/node/21869 and this is also a nice spot to start http://drupal.org/node/17272 on your experimentation. If you come up with anything different, consider adding a handbook page there.
As to the obviousness of this, well, it may certainly be obvious to you, but in the 18 months I have been using Drupal sites I have not needed this functionality. I remove the logon block on the vast majority of my sites. 'Obviousness' is a matter of perspective. Your perspective will be a nice new addition to the community and we all look forward to your contributions. It'll only make things better.
-sp
---------
Test site...always start with a test site.
Drupal Best Practices Guide
-Steven Peck
---------
Test site, always start with a test site.
Drupal Best Practices Guide
Drupal modular system makes you combinative
If you are not a PHP coder, you have to screen through all possible conbinations of the material (the modules). It's a challenge, but it is rewarding.
----------
Working on a bilingual mini-portal - www.archeologic.net
thanks!!!!
Thanks to the link, because I had lost the login block and I need to login.
Thanks a lot!!!
How I Did It...
I'm using Drupal 4.6. I don't claim to be an expert, but this is how I created a dynamic 'log in' menu item, within the navigation block...
First open user.module in an editor (I use Dreamweaver) (user.module is in the 'modules' folder).
Around about line 696 you'll find a comment: '//Your personal page' below which is the if statement which appears to control the 'my account' menu item.
I copied this complete if statement, pasted it immediately below, then made adjustments to suit. (Note the addition of an exclamation mark before $user->uid to achieve the opposite of the 'my account' menu item.)
This is what I ended up with, and gave me a working, fully dynamic 'log in' menu item:
Core
This is a fairly old thread. Adapting core modules is your prerogative, but can give trouble when updating (you need to apply the change again).
After a chat on #drupal-support with JoeyDay I wrote a tiny module to accomplish this:
Save as loginmenu.module in modules/loginmenu, omit the last ?> tag.
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.
loginmenu.module above HIGHLY RECOMMENDED!
Many thanks Heine, and to anybody else who comes this way I withdraw my hacking at a core module in my previous comment and recommend using Heine's loginmenu.module.
I'm an ASP / VB / .NET person really, but I've come to like Drupal and am learning php as needed. After 10 minutes searching for a solution I tend to have a bash myself and see what happens!
Within the $items array in the loginmenu_menu function, is there an additional option to add a title attribute to the generated link? (i.e. <a href="login" title="THIS">Login</a>)
Adding title attribute to generated link
I've just worked this out for myself! Simply add an additional line below the one starting 'title' as follows:
Fast
You're fast!
A downloadable 4.7 version of loginmenu.module has two more settings: the text of the link and the weight in the menu. The page is in Dutch.
(I haven't tested whether it has an effect on caching)
--
Tips for posting to the forums.
When your problem is solved, please post a follow-up to the thread you started.
Here is a revised version
Here is a revised version that makes the menu item movable, like Logout is. Tested in 4.7.
Save as loginmenu.module in modules/loginmenu, omit the last ?> tag.
Downloadable Module File
I have attached a downloadable copy of this file to issue 74706.
Login Menu project
I've created a project to house the module referenced.
http://drupal.org/project/loginmenu
Getting the 'Login' menu item on a custom menu
Hi,
Tried your module and it works fine but only for the default Navigation menu. I need the same functionality but on a custom menu. When I've attempted to make such a menu item it never appears. Any suggestions?
Thanks,
John.
I made an "Account Menu" derivation of this.
I wanted the same thing, pretty much, except for with the account menu. I modified the login menu to do this; you can grab it from here (its attached to the post): http://www.cosky.com/a_year_with_drupal
Not sure it's worth a whole project or if it should be packaged with other little menu things like login. Or unified somehow. Anyway, I hope someone else gets some use out of it.
Cheers,
- Eric Cosky
http://www.cosky.com