I'm using the content profile module. When a user is on their view profile page and press edit, they expect the profile edit page to show, not account settings as it is now. The path to content profile edit page is 'user/%/edit/uprofile'. Does anyone know how to set the 'user/%/edit/uprofile' to default tab for 'user/%/edit'?
相关问题
- Views base64 encoded blob in HTML with PHP
- Laravel Option Select - Default Issue
- PHP Recursively File Folder Scan Sorted by Modific
- Can php detect if javascript is on or not?
- Using similar_text and strpos together
Edit 2 (for Content Profile)
This example is for a Content Profile tab. Just change
$type
to the short name of the content type for the profile. This also shows how to clean up the code for real-world use (my previous examples were really, really verbose):Edit 1 (for Core's Profile module)
I didn't realize you wanted to change the default tabs under Edit. It's the same general principle as I described below, but with some minor modifications. This example will make the Personal tab (at
user/<UID>/edit/Personal
) default instead of the account tab:Overview and Concept
You can do this with
hook_menu_alter
and changing the types for specific tabs.Changing the default tab is a little bit of a harrowing process. Basically, the default tab inherits all the properties of the page without any tabs selected. This allows a user to go to
user/UID
and get the view page without having to go directly touser/UID/view
.To get a clearer understanding of this, check out the
user_menu()
hook implementation. Note how$items['user/%user/view']
is pretty empty, and$items['user/%user_uid_optional']
contains all the settings you would've expected to see under$items['user/%user/view']
.So, you're going to first set up the view tab to act as a regular tab: to do this, you're going to have to copy all the settings that are attached to the
user/UID
menu item and put them into theuser/UID/view
menu item.Once you do that, you're going to replace the settings for
user/UID
with the settings for the tab you want to become the default tab.Finally, you're going to unset all the menu items for the default tab since it will inherit the settings for
user/UID
.Check out this code which makes the Edit tab default:
Replace the second part of the function with the settings for your menu item and you should be in good shape. Of course, remember to clear the cache after making any menu changes for them to take effect.
I was searching for a solution but wasn't satisfied with such complexity. I did it like this.
There is a module on drupal.org. Works with profile fields. See Profile Tools.
Here's the code that worked for me with content profile installed and the default content type ('profile'):
Change
$userprofile = $items['user/%user_category/edit/profile']
to match the content profile path you need (in your case this would be$userprofile = $items['user/%user_category/edit/uprofile']
Also make sure your module runs after the content_profile module (your module must have a 'higher' weight than -1, which is content_profile.module's weight). Modules have a default weight of 0 so you should be fine there.