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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Darvanen created an issue. See original summary.

darvanen’s picture

Issue summary: View changes
darvanen’s picture

Issue summary: View changes
Matroskeen’s picture

Issue tags: +LutskGSW18
darvanen’s picture

Assigned: darvanen » Unassigned
vakulrai’s picture

Status: Active » Needs review
FileSize
582 bytes

@Darvanen I am adding a patch, hope it might work for you.

thanks.

Status: Needs review » Needs work

The last submitted patch, 6: currentpagealias-2925928-6.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

Prashant.c’s picture

Status: Needs work » Needs review

@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.

darvanen’s picture

@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.

darvanen’s picture

Issue summary: View changes
darvanen’s picture

Status: Needs review » Closed (won't fix)

I asked @berdir on Slack about this and their response was

@darvanen not so sure about "It is possible (and sometimes desired) for a node to have multiple aliases", I doubt that will work if you use redirect.module and its canonical redirect functionality (which imho everyone should and will at some point maybe get into core)

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.