Problem/Motivation
Proposed resolution
Remaining tasks
User interface changes
API changes
Original report by @catch
If you want to change the path alias for a user, you have to first find the user and their uid then go into the path admin interface, find the alias, then edit it. This takes ages.
We should add a path alias form to the user edit screen if path module is enabled - same as is currently done for nodes.
Comment | File | Size | Author |
---|---|---|---|
#127 | interdiff_121-127.txt | 1.32 KB | narendra.rajwar27 |
#127 | 476294-127.patch | 3.58 KB | narendra.rajwar27 |
#124 | afterPatch(2).JPG | 48.02 KB | pankaj.singh |
#124 | afterPatch(1).JPG | 76.04 KB | pankaj.singh |
#124 | beforePatch(2).JPG | 63.1 KB | pankaj.singh |
Comments
Comment #1
catchComment #2
elvis2 CreditAttribution: elvis2 commentedHey catch, I would like to tackle this. I am wondering, should the patch live in path or user module? Or a module of it's own?
And, merlinofchaos mentioned "toolbox" here: http://drupal.org/node/475968#comment-1641244
Is there already a helper module in place that deals solely with paths and url aliases?
Comment #3
catchI'm not aware of one (although that doesn't mean it doesn't exist). One thing which would be similar to merlinofchaos' idea would be a menu link which lets you edit aliases for the current page - ideally we'd have a path like admin/settings/path/node/1 to point to but that doesn't exist.
Comment #4
tylor CreditAttribution: tylor commentedI was looking at this one too as it's very similar to #476290: Add path alias to taxonomy term edit. It seems to me you should be able to achieve this just with path.module by using hook_user() and hook_form_alter() in a similar manner as is currently done with nodes. This is the approach I took to implement this for taxonomy.module (patch here: http://drupal.org/node/476290#comment-1853636).
Anyway, glad for the discussion and curious what the best approach will be.
Comment #5
elvis2 CreditAttribution: elvis2 commentedyes catch, do you have a recommendation on where this extra code should reside? I am wondering if there is some type of policy or coding standards when dealing with core. Do we add code to path.module or to user.module - to handle this issue?
Comment #6
stBorchertHere we go.
Comment #8
stBorchertNext try.
Comment #9
psicomante CreditAttribution: psicomante commentedcleaned form api (textfield doesn't support collaps[ed|ible]
tested and reviewed (code and functionality)
Comment #10
psicomante CreditAttribution: psicomante commentedAre you sure that put these functions on path.module is the correct way?
Comment #11
Bojhan CreditAttribution: Bojhan commentedNeeds screenshot.
Comment #12
psicomante CreditAttribution: psicomante commentedi hope this screenshot is that you're lookin' for :P
Comment #13
stBorchert@Psicomante: Yes it needs to be in path.module because otherwise you'll have to check in user.module if the module "path" is installed. It would work but its cleaner to inject the path settings via form_alter in path.module.
Comment #14
burningdog CreditAttribution: burningdog commentedI tested the patch from #9 and it looks good. I was able to add a url alias when editing a user (which worked), visit the url, remove the url, add it directly as a url alias in admin/settings/path and edit it again, and also remove it - that all worked fine :)
There were a few minor formatting issues with the comments - I've re-rolled with those fixed (thank you, coder module!).
Comment #15
chachasikes CreditAttribution: chachasikes commentedtrying this issue out as my first patch review
Comment #16
chachasikes CreditAttribution: chachasikes commentedHi catch!
I reviewed this patch (and this is my first review, btw)
The patch itself works. I was also able to apply the patch and then add an alias to user accounts. Visiting the alias also worked.
(I'm still figuring out how to make patches from my drupal install -- so I'm just pasting some code for you here.)
However, a few things are necessary for this patch, mostly comments.
1. Here is the beginning of a comments for the new function: _path_user_form_inject_path(&$form)
/**
* Add path settings to user register form.
*
* Returns fieldset with URL path settings.
* This allows a URL alias to specify an alternative URL by which the user's profile can be accessed.
*/
function _path_user_form_inject_path(&$form) {
2. This function could use more comments (what form elements you are adding and why) However, no one else in Drupal 7 has done this for any form altering functions. That seems kind of a bad practice, especially when there are dozens of form_alter calls and they all do different things. So, while I am not recommending that you add any more comments for this...I would personally like to find out why this is a common practice in Drupal.
path_form_user_profile_form_alter(&$form, &$form_alter) {
3. This function could use some documentation for the arguments (though this one is probably also a drupal-wide problem.) I ask because it is not immediately apparent what the &$edit variable is, or what the $category is....:
function path_user_submit(&$edit, &$account, $category = NULL) {
4. Is 'inject' the best word for a function name? (I'm not sure) There were not any other functions in d7 with that word in it. I did find the word 'inject' in the code, but it was in the doc-block for the function. Maybe you could change the function name from _path_user_form_inject_path _path_user_form_path ?
Here is a similar example:
/**
* Inject links into $node for attachments.
*/
function upload_node_links($node, $build_mode) {
$links = array();
Other things I thought about, but decided it was OK the way you did it (at least from my perspective)
a. setting access permissions to user 'create URL alias' - This makes sense because only users who can edit users can adjust the user alias. This is totally different than, say, adding taxonomy terms for users & classifying them.
b. not setting the default alias to 'user/useralias' -- i think it makes sense to create ANY alias you want - and that can be configured with pathauto
Other things to test
This module should be tested with pathauto, that pathauto filters will work with users.
Comment #17
chachasikes CreditAttribution: chachasikes commentedunassigning this issue
Comment #18
stBorchert@chachasikes
Thanks for your review.
@1.: Added comment to function.
@2.: Added some comment.
Why it (and what exactly) is "bad practice"? Using a helper function to add the form elements rather than inserting duplicate code?
Or do you mean the use of hook_form_FORM_ID_alter?
@3.: http://api.drupal.org/api/function/hook_user/7
hook_user_submit
doesn't have its own document page, yet.@4.: I've chosen "inject" because thats what it does. It injects some elements into an existing form. But I'm not nailed down to this wording ...
Comment #19
Shawn DeArmond CreditAttribution: Shawn DeArmond commentedPatch works as advertised. Good idea!
Comment #20
cwgordon7 CreditAttribution: cwgordon7 commentedComments should wrap at 80 characters.
Comments should wrap at 80 characters.
Comments should wrap at 80 characters.
Can we expand this logic into multiple lines for increased code readability?
Other than that, looks pretty good.
Comment #21
stBorchertNew patch with updated comments.
Comment #23
stBorchertArgh, this is because I can only use
diff
instead ofcvs diff
here. Will reroll later today.Comment #24
stBorchertUpdated the patch (again).
Comment #26
stBorchertDear bot: please retest.
Comment #27
arianek CreditAttribution: arianek commentedpatch applied cleanly to head - reuploading for test bot
Comment #28
Bojhan CreditAttribution: Bojhan commentedAll cwgordons issues have been adressed, back to RTBC?
Comment #29
sunI don't agree with the approach taken here. Instead of introducing new functions that almost match the existing functions, the existing functions should be extended to work for more entities/object types.
Comment #30
webchickAdditionally, could I get clarification on the use case here?
Taxonomy terms I get. It's very conceivable that you have a free-tagging vocab where you don't really care what the URLs are, but in your "Product Type" vocabulary, you specifically want URLs like example.com/tshirts, example.com/videos, etc.
But users? Is there a use case for user/1, user/2, user/3, user/tom_the_frightening_toast?
Seems like this is a classic case where you'd want a pattern-based URL-generator like Pathauto, not a one-off thing, which would result in terribly inconsistent user profile URLs.
Comment #31
sun@webchick: A form widget to enter any URL alias for a user is a pre-condition for auto-generated aliases. You always need a way to override those.
Comment #32
sunIntroducing a new tag for feature freeze: API clean-up.
Comment #33
sbefort CreditAttribution: sbefort commentedSubscribing.
Comment #34
webchickComment #35
Dave ReidI think we'll likely accept a patch in Pathauto for D7 to add this to the user forms.
Comment #36
cosmicdreams CreditAttribution: cosmicdreams commentedGiven the new approach proposed in #29, is this still a Novice issue?
Comment #37
andypostSuppose this should be done inline with #2201051: Convert path.module form alters to a field widget
Comment #38
andriyun CreditAttribution: andriyun commentedComment #39
andriyun CreditAttribution: andriyun commentedComment #40
sanchiz CreditAttribution: sanchiz commentedThere is patch which works with another patch from parent issue https://drupal.org/node/2201051#comment-8722973
Comment #41
sanchiz CreditAttribution: sanchiz commentedComment #43
sanchiz CreditAttribution: sanchiz commentedPostponed to #2201051: Convert path.module form alters to a field widget
Comment #44
sanchiz CreditAttribution: sanchiz commentedComment #45
sanchiz CreditAttribution: sanchiz commentedContinue work.
Comment #46
sanchiz CreditAttribution: sanchiz commentedComment #47
sanchiz CreditAttribution: sanchiz commentedComment #48
tmbritton CreditAttribution: tmbritton commentedI tested patch, seems to work correctly.
Comment #50
sanchiz CreditAttribution: sanchiz commentedStill no updates?
Comment #52
realityloopReroll
Comment #53
BerdirI'm not sure sure this makes too much sense unless you use it in combination with pathauto and then possibly only for administrative users? You wouldn't want to give your users full control over the alias they can use? The only thing you might want to is have a field where they can for example control /user/[something], then you'd in turn use pathauto to generate the actual path.
What I have in mind is a feature for pathauto in 8.x that allows to simply check of which entity types should have this field, which at the same time would also enable them to have pathauto alias patterns.
Comment #54
a_thakur CreditAttribution: a_thakur commentedThe patch does not apply to latest drupal 8(branch 8.0.x) code base.
Comment #55
amitgoyal CreditAttribution: amitgoyal commentedRe-rolled patch in #52.
Comment #56
garphy CreditAttribution: garphy commentedComment #57
sanchiz CreditAttribution: sanchiz commentedComment #58
Jalandhar CreditAttribution: Jalandhar commentedThe patch does not apply to latest drupal 8(branch 8.0.x) code base.
Comment #59
er.pushpinderrana CreditAttribution: er.pushpinderrana commentedReolled #55 patch.
Comment #61
andriyun CreditAttribution: andriyun commenteder.pushpinderrana
Your patch is missing closing curly brace in 113 line
/core/modules/path/path.module
There should be closing brace
Comment #62
andypostsure, still need re-roll
Comment #63
cosmicdreams CreditAttribution: cosmicdreams commentedrerolled.
Comment #65
andypostform state should be a class #2335659: Remove FormState ArrayAccess usage from core
Comment #66
estoyausenteI have changed it. It seems that run ok.
Comment #67
estoyausenteComment #69
estoyausenteNow it pass this test in my local.
Comment #70
estoyausenteComment #72
star-szrLooks like this needs another reroll.
However it's worth pointing out that this is currently filed as a 'Feature request' so it's more likely that this would be added to 8.1.x than 8.0.x.
Comment #73
estoyausenteYes, really I think that is better wait for a more stable 8.0.x for do the rerolling. Ty for all Cottser. :)
Comment #74
rpayanmComment #77
ravi.khetri CreditAttribution: ravi.khetri commentedRerolled.
Comment #79
adci_contributor CreditAttribution: adci_contributor commentedI'm just fixed an endline and cleaned a whitespace in #77.
Comment #81
balsamaComment #82
balsamaComment #83
balsamapath_alias_user-476294-79.patch queued for retesting.
Comment #84
balsamaComment #85
Dom. CreditAttribution: Dom. commentedJust changed patch from @adci_contributor #79 to make it applying current HEAD.
Also tested it: it works, but I let someone else RTBC ! ^^
Comment #87
Dom. CreditAttribution: Dom. commentedOups!
Just re-rolling patch under 8.0.x-dev !! (héhé)
Comment #88
Dom. CreditAttribution: Dom. commentedComment #89
andypostThe
path_settings_form_element()
is not actually reusable because assumes$form['path']
so maybe better to implement that function with argument of path field?Also usage of this details could be configured on path field widget...
A bit confusing to have details on user and node forms but no on taxonomy term
Comment #91
dcmul CreditAttribution: dcmul as a volunteer commentedBut do we really need details on user form? and not on taxonomy form?
Why don't we implement path in user the same way it was done for taxonomy, with no details.
And on approach
that line seems redundant, since there is no advanced group in user form unlike node form.
Comment #92
dawehnerThank you for the work on that.
Why do we consider doing a feature request for 8.0, that certainly sounds like 8.1 material for me.
Comment #93
lauriiiComment #96
ieguskiza CreditAttribution: ieguskiza as a volunteer commentedHi,
I'm submitting a tentative patch to harmonize the behavior of the path field inside entities.
As noted in previous comments it makes no sense for the path field to be inside details on the node form but not on taxonomy or user ones so I harmonized it and added it inside details in all forms.
Part of the Drupalcon Dublin 2016 sprints.
Comment #98
ieguskiza CreditAttribution: ieguskiza as a volunteer commentedResubmitting the previous patch in order to pass tests.
Comment #99
ieguskiza CreditAttribution: ieguskiza as a volunteer commentedComment #100
criscomI will review the patch by ieguskiza in #98 on Drupalcon Dublin.
Comment #101
marabak CreditAttribution: marabak at Lumini commentedthe patch is not applying
i re-rolled it
Comment #102
criscomThe patch applied cleanly for me.
Downloaded and enabled pathauto, token and ctools.
Set a url path for my user.
Working perfectly.
Comment #103
BerdirThis patch is not needed for pathauto to work, as it has settings that allow to enable the field on every entity type.
I do not think having this makes sense without automatically generated aliases, so I'm kind of -1 on adding this to core.
Comment #105
ieguskiza CreditAttribution: ieguskiza as a volunteer commentedThe same could be said for taxonomy terms but I guess it was decided to add them directly through the path module because of the widespread usage we give to aliases in regards to these entities.
That being said, I agree that assuming the same usage for user entities is quite far-fetched and probably a very specific case for certain sites. Also the path field was never added for users in the core of Drupal 7 to begin with, so even though I provided a patch for this feature I will also say that we would be better of scrapping it.
Comment #107
pk188 CreditAttribution: pk188 at OpenSense Labs commentedRe rolled #98 as not applied.
Comment #109
rajeshwari10 CreditAttribution: rajeshwari10 as a volunteer and at Valuebound commentedComment #110
rajeshwari10 CreditAttribution: rajeshwari10 as a volunteer and at Valuebound commentedI have done changes in "core.entity_form_display.user.user.default.yml" as the error was coming from file.
Please Review
Thanks!!
Comment #118
sharma.amitt16 CreditAttribution: sharma.amitt16 as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedThe patch is not applying on the D9.1.x branch.
Re-rolling the patch for the same.
Comment #120
sharma.amitt16 CreditAttribution: sharma.amitt16 as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedComment #121
sharma.amitt16 CreditAttribution: sharma.amitt16 as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedBelow is the output of test cases that are passed on local which are failed in the previous patch.
Comment #122
sharma.amitt16 CreditAttribution: sharma.amitt16 as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedComment #123
narendra.rajwar27@sharma.amitt16, I have tested by applying this patch, and the path alias functionality working fine.
Comment #124
pankaj.singh CreditAttribution: pankaj.singh as a volunteer and at Srijan | A Material+ Company for Drupal India Association commentedTested the patch given in #121. Patch applied successfully and changes are reflecting with custom path aliasing.
Please refer to SS for ref. RTBC+1
Comment #125
PapaGrandeSmall nit, but since you are defining
$default_entity_types
twice in the module, I wonder if it makes sense to create a constant or helper function to get the array values. Then it can be well documented, and if a new entity type is added, it only has to added in one place.Otherwise, the code looks good.
Comment #126
narendra.rajwar27Working on it.
Comment #127
narendra.rajwar27@PapaGrande, Thank you for review. Updating the patch as comment #125
Comment #129
narendra.rajwar27Test case failed due to random failure, adding test again passed. changing issue status.
Comment #130
PapaGrandeSuccessfully tested by a few people and the code looks good to me. Well done!
Comment #131
catchWith the base field definmition, path_form_alter() shouldn't be necessary here - we already show the field on the node form without this alter being in place. If it is necessary, then something seems wrong.
Comment #132
BerdirThat logic was moved to Drupal\path\Plugin\Field\FieldWidget\PathWidget::formElement(), dynamically based on the advanced key.
This is based on very old patches and was rerolled incorrectly from that as that part has been removed.
That said, I'm still not fully convinced about doing this by default. I think aliases for user profiles is a _very_ rare use case, especially creating them manually. What is the use case for that when you don't use pathauto? And if you do, it's just a checkbox to enable it for user (like any other entity type as well).
Comment #138
acbramley CreditAttribution: acbramley at PreviousNext for Service NSW commentedIs this a duplicate of #1057570: Create user/edit menu path to edit the current user's account? They sound very similar but have completely different solutions.