For a Drupal 6 site I'm doing, it seems more appropriate for 开发者_开发技巧the "user edit" section to be called "Settings" than "Edit". I'd like to make this change, down to the point where the URL would be example.com/user/foo/settings. I've been mucking around in _menu and _menu_alter handlers and the like, but haven't found a clean way to do this. Is there one? Any advice out there (other than "don't do it")? Thanks!
Well, yeah, the first thing that comes to mind is Don't Do It, especially if you mean eliminating ".../edit". You can imagine that other modules (especially contrib ones) might assume on user/%/edit in order to generate their links and stuff.
But if you just have to do it for some reason, then it'd have to be something like:
<?php
/**
* Implementation of hook_menu_alter().
*/
function MYMODULE_menu_alter(&$items) {
$items['user/%user_category/settings'] = $items['user/%user_category/edit'];
$items['user/%user_category/settings']['title'] = 'Settings';
$items['user/%user_category/settings/account'] = $items['user/%user_category/edit/account'];
unset($items['user/%user_category/edit'], $items['user/%user_category/edit/account']);
}
This will essentially eliminate the original "/edit" callbacks.
A better option (since, like I said, other modules/themes/etc you install in the future might assume the existence of the ".../edit" URLs) would be to have both, with the new one being just a copy of the original:
<?php
function MYMODULE_menu_alter(&$items) {
$items['user/%user_category/settings'] = $items['user/%user_category/edit'];
$items['user/%user_category/settings']['title'] = 'Settings';
$items['user/%user_category/settings/account'] = $items['user/%user_category/edit/account'];
$items['user/%user_category/edit']['type'] = MENU_CALLBACK;
$items['user/%user_category/edit/account']['type'] = MENU_CALLBACK;
}
Notice I changed the original ".../edit" items' type to *MENU_CALLBACK* (they're *MENU_LOCAL_TASK* and *MENU_DEFAULT_LOCAL_TASK* originally), because if you leave them all as local tasks, then you will see two "edit" tabs in the user profile, admin menus, etc.
Clear the cache and good luck!
精彩评论