Closed (duplicate)
Project:
Pathauto
Version:
5.x-2.x-dev
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
16 Dec 2006 at 08:44 UTC
Updated:
3 Oct 2007 at 06:24 UTC
Jump to comment: Most recent file
Comments
Comment #1
gregglesThis is a duplicate request to http://drupal.org/node/32958
I'm not really sure how I feel about what pathauto should be doing in this situation, but I'd be willing to apply a patch that checks for a user entered alias and uses that instead of generating one at node creation/edit time. That seems like it might get complex, but I'd be interested in hearing ideas and seeing code (though not in writing code myself).
You may be interested in urlify module which has similar features but works better with manually editing the paths.
Comment #2
lbh commentedOh sorry, I browsed to see if anybody else had taken note of this, but I must have overlooked the previous request. I'm actually pretty happy with pathauto module, I'd just prefer the option to have it not create an additional alias when a user defines one at node creation. I wasn't sure whether this was the desired behavior, or perhaps a bug. I suppose I could always remove the undesired aliases manually.
I'm new to both Drupal and coding, but I'm more than willing to give it a try (and embarrass myself). I seemed to have gotten something working, but I'd venture to guess there's plenty I'm overlooking. Perhaps there is a better way to do it, I'm not sure.
I created an option, so you can have the default behavior:
Then I wrapped the contents of the pathauto_create_alias() function in a conditional statement:
I'm guessing that even if by some measure this is a decent way of doing this, there is probably a more Drupal specific variable than $_POST['path'].
Comment #3
gregglesGreat start!
Can you post it as a patch?
http://drupal.org/diffandpatch
Comment #4
lbh commentedThanks. I see why open source is addictive. :)
Anyway, here's the patch...
Comment #5
lbh commentedComment #6
greggleslbh - so, I'm looking into this and thinking about the if you created:
My concern is how this will work if you are editing a post. If you are editing a node the path input box is populated. If you then change the title of the post (which would change the url) and leave the path box populated then your url will not be updated. I believe that is undesired behavior for the majority of users of pathauto.
I also think that the options could be improved (and therefore the underlying code would need to be improved). The options I would like:
1. If a path is entered at node creation/edit then do not automatically create one
2. If a path is entered at node creation/edit then ignore it and automatically create a path based on the pathauto patterns
3. If a path is entered at node creation/edit then create both the user-entered path and the path based on pathauto patterns as duplicates of each other
Perhaps there are more options - what do you think?
Comment #7
lbh commentedYou're absolutely right, I didn't consider what would happen when editing a node. Sometimes it's annoying wanting to help but being a bit unexperienced (and sometimes confused). I think the Drupal-Dojo lessons should help though, little by little. Perhaps I'll play around with it some more; it might offer a good learning opportunity.
On a side note, I think that lately my brain is mostly consisted of mashed potatoes. :)
Comment #8
gregglesSo, just to be clear (since others are asking for this same feature) I think the only solution is to do a form_alter on the node_edit form, if the user can create aliases then insert a checkbox, if the checkbox is checked then use the alias provided in the manual alias creation form.
The checkbox default state should be off. Ideally some javascript should automatically check the box if the user types in the manual path alias box.
If the checkbox is checked and the path alias box is empty then it should probably still not create an alias.
Comment #9
gregglesI'm changing the title to be more reflective of what the code should do.
As I think about this even more, we really just want pathauto to not create any aliases for these nodes. If you manually enter an alias or not...shouldn't matter to this option.
Comment #10
freeman-1 commentedGreggles,
thanks for pointing me to this - from my "manual overrride" issue; and also suggesting URLify. Fact is I do a lot of programmatic node creation/update. So the Javascript edit-time feature doesn't help much.
I've been browsing the module code and I just couldn't tell why 'page' types can be set manually - e.g. the title is 'Page 11' but I could set the path as pager11s'. And it sticks. I couldn't do so for other types - story and CCK custom types.
If we could identify why this is so, would it be possible to replicate it to other types with some minor code changes ?
(I recall reading somewhere that the way to use pathauto was to leave the path field as blank if I wanted it to takeover and auto-generate the path URL alias. Otherwise, the URL alias will use whatever is typed there. I can't seem to dig out where I read that though)
Comment #11
gregglesIf it "works" as you expect for pages, but not other nodes then pages are also broken - just in a different way than the other content types.
The right solution, in my mind, is still the checkbox idea that I outlined in #8.
Comment #12
freeman-1 commentedI've fiddled around more with the pathauto module settings and it seems I could now create new nodes for other types with manually set paths. So it seems there are some (initial) state-related issues there, or I just need to more fully understand this module.
I'll open a new issue if I can replicate my original problem again.
Comment #13
gregglesN fixed via http://drupal.org/node/170673 so I'm marking this as a duplicate of that...
Yay features!
Comment #14
lbh commentedThis is a great and simple solution!
I haven't really been around much except in the past couple of weeks. Strangely, one of my frustrations is that I'm perhaps not skilled enough to help out where I'd like. :)