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.
Problem/Motivation
It is possible (and sometimes desired) for a node to have multiple aliases. A number of tokens that have [current-page:url] as a parent do not consistently return the value that is in the address bar.
For example: on a page with two aliases ("/test" and "/second-alias"), [current-page:url:brief] returns one of those values seemingly at random with no regard to which alias is actually being visited.
Proposed resolution
Unsure. Maybe one of:
- Pass some options from the [current-page] token when chaining to [*.url]?
- Test for
'<current>'
when building the [*.url] token and and use$_SERVER['REQUEST_URI']
instead of$path_url->setAbsolute(FALSE)->setOption('fragment', NULL)->getInternalPath();
?
Remaining tasks
Determine best approach
Comment | File | Size | Author |
---|---|---|---|
#6 | currentpagealias-2925928-6.patch | 582 bytes | vakulrai |
Comments
Comment #2
darvanenComment #3
darvanenComment #4
MatroskeenComment #5
darvanenComment #6
vakulrai CreditAttribution: vakulrai as a volunteer and at gai Technologies Pvt Ltd for gai Technologies Pvt Ltd commented@Darvanen I am adding a patch, hope it might work for you.
thanks.
Comment #8
Prashant.c@Darvanen
In the latest code of the module i don't see any token with the name
[current-page:url:alias]
And from For example: on a page with two aliases ("/test" and "/second-alias"), [current-page:url:alias] returns one of those values seemingly at random with no regard to which alias is actually being visited. it seems like you are taking about page arguments if this is the case then you can use
[current-page:url:args]
token.Comment #9
darvanen@Prashant.c okay so it's been refactored... let's go with
[current-page:url:brief]
which is in the token help page.@vakulrai your approach works for this use-case but I wonder if it might break some other things? Perhaps we need a maintainer to weigh in here.
Comment #10
darvanenComment #11
darvanenI asked @berdir on Slack about this and their response was
I am no longer working on the project that led to this issue, however I think it was around the idea of leftover aliases from when they are changed, which the redirect module does handle. I think we can close this.