Provide suggested log-in item for navigation menu
Darren Oh - July 20, 2006 - 17:21
| Project: | Drupal |
| Version: | 7.x-dev |
| Component: | user.module |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | needs work |
Description
This issue was brought up in forum post 14223. Someone provided instructions for creating a module to add log-in to the navigation menu. It seems more appropriate to add this function to the core user module.
The code for the function is this:
function loginmenu_menu($may_cache) {
global $user;
$destination = drupal_get_destination();
$items = array();
if($may_cache){
$items[] = array(
'path' => 'login',
'title' => t('log in'),
'access' => !($user->uid),
'callback' => 'drupal_goto',
'callback arguments' => array('user/login', $destination),
'weight' => -10,
'type' => MENU_DYNAMIC_ITEM | MENU_NORMAL_ITEM,
);
}
return $items;
}I'm also attaching a copy of the module.
| Attachment | Size | Status | Test result | Operations |
|---|---|---|---|---|
| loginmenu.module | 1.11 KB | Ignored | None | None |

#1
+1 on the idea. This way, the login link can even be added in the primary/secondary links, if wanted.
please provide a patch against cvs.
http://drupal.org/patch
#2
I tried adding the code to the user module, but it didn't work.
#3
the code is designed like an independent contrib module.
Just keep the active part:
<?php$items[] = array(
'path' => 'login',
'title' => t('log in'),
'access' => !($user->uid),
'callback' => 'drupal_goto',
'callback arguments' => array('user/login', drupal_get_destination()),
'weight' => -10,
'type' => MENU_DYNAMIC_ITEM | MENU_NORMAL_ITEM,
);
?>
to be added, I guess, in user_menu().
#4
I must have had some typos in the code. This patch works fine.
#5
- This should be a MENU_SUGGESTED_ITEM so it is hidden by default and can be easily enabled via the menu administration.
- This should change the existing menu item instead of creating a different one that only redirects.
#6
I modified the patch to make login a suggested menu item. It's not possible to modify the user/login item because it works differently from the login item. user/login redirects to the users account if the user is logged in; login is not accessible to users who are logged in.
I put the code for the login menu together with the code for the logout menu to make its function clearer.
#7
I still don't like the idea of adding a duplicate menu item for this.
Please do not mark your own issues as ready to commit, this needs someone to review it.
#8
I don't understand why this would be a duplicate menu item. The existing user login uses the menu system but does not provide a menu item. It requires a block. It seems consistent that if logout is a menu item, there should be an option to make login a menu item also. If someone redesigns the existing login to show up in the menu I will be glad to close this issue. At the moment my programming skills aren't up to it.
#9
As this issue is not going anywhere, I've created a project to house the module referenced.
http://drupal.org/project/loginmenu
#10
Thank you. I hope this gets in core soon. I don't know why this has been made such a big issue that we have to have a separate project for it.
#11
#12
As long as this is considered a feature this is unlikely to get it until 6.
I suggest campaigning for it on Development list if you think it's a good idea.
#13
#14
patch no longer applies
# patch -p0 < user.module.login-link_0.patch
patching file modules/user/user.module
Hunk #1 FAILED at 741.
1 out of 1 hunk FAILED -- saving rejects to file modules/user/user.module.rej
[root@h99846 test]#
#15
subscribing
#16
Too late for D6. Moving to the D7 queue.
#17
Here's an updated patch. The problem with this patch is that combining a suggested item with a local task appears to make the suggested one normal (and active), because the local task part is active. That means if you apply this patch and view Drupal while logged out, you'll get both a Log in link and a login form block. The original patch was able to abuse having two different array options, but I think this should figure a way to use the same one.