Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When generating a new url when the same url is already exists, pathauto creates urls with postfixes -0 -1 and so on. Is it possible to grant feature that makes them more customizable. For example:
news/2007/09/28 ---> news/2007/09/28/1
news/2007/09/28-0 ---> news/2007/09/28/2
news/2007/09/28-1 ---> news/2007/09/28/3
news/2007/09/28-2 ---> news/2007/09/28/4
Comments
Comment #1
gregglesThis would require a fair amount of work for little value (in my opinion).
I'd be willing to commit a small patch that can achieve this, but I'm not going to write or test it.
Comment #2
gregglesAlso, when the first one is entered there's no way for pathauto to know that the second one will come, so are you suggesting that all urls get a "/1" on the end? Or are you suggesting that when the second one comes in the old one gets updated (causing linkrot...)?
That "/1" part of this is one thing that I'm pretty concerned about, so any implementation should be particularly careful in that area (or just not do it).
Comment #3
gregglessorry, forgot to finish updating the title
Comment #4
Nilard CreditAttribution: Nilard commentedI suppose an option, and when the user checks it, then it is expected that where will be more then one url generated with this template. So the first url becomes /1, second /2 and so one. When the option is unchecked then urls are created the way they are created now.
Comment #5
Dave ReidFeature requests for 6.x-2.x only.
Comment #6
nw CreditAttribution: nw commentedNot sure if this is the right thread for my comment, given the current issue settings! However, here is my 2¢ worth:
I like the idea and see a use for it. As it happens it is possible to configure the separator character in 6.x-1.3 since this value is stored as a Drupal variable. In function in pathauto.inc we have:
Using the developer module, I have set the seperator to '/'. However, pathauto is hardcoded to start numbering at 0. It is trivial to patch this for more flexibility. In my dev environment I have:
Currently this would give item, item/1, item/2, item/3 whereas what I think most users will want item/1, item/2, item/3, item/4
My next goal is to ensure that we can control this. Watch this space.
Comment #7
nw CreditAttribution: nw commentedI now have a prototype solution to the problem identified by me in #6. What I have done is build in a pseudo-token. What I have for an Automated alias settings is:
item/{seq}
In which case, my modified pathauto module produces aliases item/1, item/2, item/3, item/4 and item/5 for the 5 item nodes I have in my test environment.
What is the best way to disseminate my changes? Attach a patch to this issue? If yes, I'll endeavour to do so ASAP after I figure out how to do it.
Comment #8
Dave ReidComment #9
Georg CreditAttribution: Georg commented#328064: Option to add a suffix/extension to aliases, by setting a place for the numbering was merged with this issue and was marked duplicate in favor of this older issue.
Comment #10
porg CreditAttribution: porg commentedI also would like to control the behavior.
1) I would like to have no dash between the item and number.
2) I would like to start counting with 2. Why? First normal users start counting with 1 rather than 0 (as programmers do), and second, I consider 1 correlates to the first alias which uses the path, and hence the first duplicate starts to get 2.
So did nw's changes from #6 get commited?
I don't see any appropriate configuration possibilities in the 6.x-2.0-alpha3 GUI.
If one wants to control the behavior, must one modify the module's code?
Or write an override function in the template.php ?
Comment #11
iantresman CreditAttribution: iantresman commentedYes please! It would be nice if I could configure the numeric suffix appended to URL aliases to make them unique, eg, the suffix:
Option 1 is most important. It could be implemented if there was a "unique suffix token", and I could specify a URL pattern thus:
In Drupal 6, the current behavior is hardwired in
function pathauto_clean_alias
in the submodulepathauto.inc
.