Posted by spessex on June 26, 2012 at 11:27am
Hi
Does anyone know of a way to get a link in Drupal to go direct to the 'Edit' tab/page as opposed the usual 'View' tab/page?
To be clear I am using Profile2 and have a link to a profile page from the user menu. At the moment when they click this they are taken to the 'View' page where they then have to click the 'Edit' tab to make changes to their profile. I'm not too confident of all users working this out so would prefer them to go straight the 'Edit' page.
I'm using the standard D7 Bartik theme should this be relevant.
Any help would be greatly appreciated.
Thank you
Stephen
Comments
So, you could just create a
So, you could just create a new menu item, and append '/edit' to the edit, which should take you to the correct page, but I guess in your case, you want to link people to their account edit page, which includes a wildcard, so you want the link to look something like: '/user/%uid/edit'.
You can probably use page manager, which is part of the ctools suite and create a new URL, say: 'account/edit' and set up a redirect using either the HTTP response code handler, or page manager redirect. Then put that link into your menu.
Thanks Steve
Thanks Steve I'll take a look at this and see if I can get it to work.
PS The URL for the edit
PS The URL for the edit profile page looks like this http://localhost/Linode/mrfgr/profile-respondent_signup_information/1/edit
What does the '1' refer to? Is it my current user ID or a node reference of some kind?
Also tried http://localhost/Linode/mrfgr/profile-respondent_signup_information/user... but getting a Bad Request page?
Yeah, so the 1 is your user
Yeah, so the 1 is your user ID. If you want a link for all users to be able to use that points at their edit page, you'll need to use something like I described above, and replace the 1 with a wildcard (of their user ID)
Just to be sure say the
Just to be sure say the original URL is:
http://localhost/Linode/mrfgr/profile-respondent_personal_infomation/1/edit
if I add the wildcard I'm assuming it would look like this:
http://localhost/Linode/mrfgr/profile-respondent_personal_infomation/%ui...
however this throws up a 'Bad Request'. What am I doing wrong here?
Views
I've used views in the past for stuff like this, creating a mini dashboard of sorts that shows the current users profile photo, links to edit their profile, etc.
Just create a user view with a User ID contextual filter. Provide a default value with the currently logged in user. Then add a User ID field.
You can rewrite the field to say "Edit Profile" or whatever you want, then output the field as a link. For the link path put "mrfgr/profile-respondent_personal_infomation/[uid]/edit". The [uid] is a token for the user ID which can be found under the collapsed "Replacement Patterns" fieldset.
Make sure you untick the box for the UID field that says "Link this field to its user" otherwise that will override the rewrite link from above.
Jeni
Hi JennieApologies for the
Hi Jennie
Apologies for the delay in replying and thank you for helping but I've been trying many different techniques to achieve my end goal but the main issue I have is that Profile2 does not appear to accept any tokens of any kind. So in your example above "mrfgr/profile-respondent_personal_infomation/[uid]/edit" Drupal will not recognise this path to a Profile type (in particular when trying to create a new menu link to a profile type - edit page). Is there something I'm doing wrong? Are you able to create a menu link to a profile type using tokens and particularly [uid]?
Thank you
Stephen
Thanks Jeni I'll take a look
Thanks Jeni I'll take a look at this.
Another option would be to
Another option would be to create a rule (Rules Module) as below..
This worked on a quick test..
{ "rules_user_edit_redirect" : {"LABEL" : "User edit redirect",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules" ],
"ON" : [ "user_view" ],
"IF" : [
{ "data_is" : { "data" : [ "account" ], "value" : [ "site:current-user" ] } }
],
"DO" : [ { "redirect" : { "url" : "[account:edit-url]" } } ]
}
}
Hi That did work (I just
Hi
That did work (I just changed it to when 'user logs in' however it doesn't take me to the actual Profile type (in this instance 'My Personal Profile') edit's page. Instead it always goes to the main user registration edit page (which includes one of my other profiles).
At the moment I have also tried which:
{ "rules_user_edit_redirect_cloned_" : {
"LABEL" : "User edit redirect (cloned)",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules" ],
"ON" : [ "user_login" ],
"IF" : [
{ "data_is" : { "data" : [ "account" ], "value" : [ "site:current-user" ] } }
],
"DO" : [
{ "redirect" : { "url" : [ "site:current-user:profile-personal-profile:user:edit-url" ] } }
]
}
}
So to be clear I have 5 profile2 types. 1 of which is included in the new user registration form. So the rules at the moment only take me to the edit page of this new user registration form (which incorporates another profile2 type - not the one I am trying to link to) AND DOES NOT take me to the other profile2 type (in this case the edit page of My Personal Profile).
Any further help would be great as I've now been on this for a solid 4 hours! ;-)
Ok I now have this going to
Ok I now have this going to profile2 type 'My Personal Profile' however I cannot appear to get it to go directly to the 'edit' page and it is still going to the 'view' page. Any ideas? See rule:
{ "rules_user_edit_redirect" : {
"LABEL" : "User edit redirect",
"PLUGIN" : "reaction rule",
"REQUIRES" : [ "rules" ],
"ON" : [ "user_login" ],
"IF" : [
{ "data_is" : { "data" : [ "account" ], "value" : [ "site:current-user" ] } }
],
"DO" : [
{ "redirect" : { "url" : [ "account:profile-personal-profile:url" ] } }
]
}
}
Thank you. I'll take a look.
Thank you. I'll take a look.
You can install
You can install http://drupal.org/project/menu_token which will allow you to use e.g. the [current-user:uid] token in a menu path.
menu token rocks!
I've just tried out menu_token and it's a great little module (despite being alpha/beta). Traditionally creating dynamic menu items in Drupal has been a real pain, but this does the job perfectly for both D6 and D7.
The D7 UI is a bit more confusing, but the tokens include [current-user:edit-url], so you don't even have to make up your own path like "user/[current-user:uid]/edit".
I'm not sure I get what you
I'm not sure I get what you need.
I used 2 modules
- Token
- Token filter
and then I set the url so:
/mydrupalinstallationfolder/user/[current-user:uid]/final-tab-you-need
http://drupal.stackexchange.com/questions/165502/link-to-a-sub-url-user-...