Score:0

How can we redirect from a node's /latest URL if there is no latest moderation state when the user clicks it?

ng flag

Drupal 9: We want to link users to the node's "/latest" URL but if there is not currently a latest version then they get an access denied message. We'd like to, instead, redirect the user to the node without the /latest

Example:

Going to site.com/node/7944/latest when there is no latest would redirect the user to site.com/node/7944

4uk4 avatar
cn flag
Programmatically? The easiest way probably would be to catch the access denied exception and set a redirect response. See https://drupal.stackexchange.com/questions/312473/redirection-from-user-login-to-another-page-for-logged-in-users
Trà Dương avatar
sa flag
I would suggest a RouteSubscriber, check and handle, redirect before it throw an exception.
quantumized avatar
ng flag
Thank you 4uk4, your suggestion worked.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.