Closed olafgrabienski closed 2 weeks ago
Two more observations:
(1) For testing purposes, I've added a "Path" field to the Manage content view. This field is supposed to show the "aliased path to content". Results in the setup described above are /hello-world
for the English page and /node/7
for the translation.
The problem seems to be how Views handles aliased paths, no matter if in a Path field or in a Title field with the option "Link this field to the original piece of content".
(2) When you switch the Backdrop interface from English to the other language (e.g. German) and visit the Manage content page again, the link to the German page points (correctly) to the path alias, and the English page link is missing the alias.
Conclusion: Path aliases in views work only if interface and content language are the same.
I can confirm this behavior. Although I had to set the detection method in /admin/config/regional/language/detection
, I reproduced your steps.
English interface: only English content gets the right alias :
Catalan interface: only Catalan content gets the right alias :
Found the bug. PR provided.
Explanation of the fix:
views_handler_field::render_as_link()
language
object to be placed in $alter['language']
. This sends the language object to function l()
to create the link based on the alias if available ππ½ views_handler_field_node
and views_handler_field_node_revision
put the fully loaded language object inside key $this->options['alter']['langcode']
ππ½ render_as_link()
to never find that language object, since it's placed under the wrong keyThe solution is to modify views_handler_field_node
and views_handler_field_node_revision
so that it puts the fully loaded language object under key language
(which, incidentally, is what Backdrop uses for language objects, as opposed to langcode
, which is used for the string language code).
It seems that the problem is fixed partially. Indeed, the link for each content shown when hovering the node title looks right, now, but not the path field.
OK, I'll take a look at that. I bet it's the same issue that I found with the link.
Actually it's a different problem. Since these are two distinct problems, can you please open a new issue for the path
Views field?
can you please open a new issue for the path Views field?
Sure, I'll do that.
Then, PR works for me.
I have a fix for the other issue as well. I'll wait until you post the new issue.
LGTM
Thank you @argiepiano! This looks like a mistake after we globally replaced "language" with "langcode", but that conversion didn't happen within Views, so it remains "language". Thank you @olafgrabienski, @robertgarrigos, and @herbdool for verifying the solution. I merged https://github.com/backdrop/backdrop/pull/4895 into 1.x and 1.29.x.
Description of the bug
Links to translated content which is listed in views, e.g. on the "Manage content" page, don't point to the aliased path.
In other words: Path aliases in views work only, if interface and content language are the same. (See next comment.)
Steps To Reproduce
To reproduce the behavior:
example.com/hello-world
.example.com/de/hallo-welt
.Actual behavior
The path to the English page "Hello World" is the alias
example.com/hello-world
(as expected). The translation "Hallo Welt" doesn't link to an alias but to the node ID path, e.g.example.com/node/7
.Expected behavior
The link to the translation "Hallo Welt" points to the alias, e.g.
example.com/de/hallo-welt
.