Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[V4] UUID permalinks still redirect to default language page #6865

Closed
dviate opened this issue Dec 14, 2024 · 6 comments · Fixed by #6982
Closed

[V4] UUID permalinks still redirect to default language page #6865

dviate opened this issue Dec 14, 2024 · 6 comments · Fixed by #6982
Assignees
Labels
critical: roadblock 🚧 Needs to be solved first
Milestone

Comments

@dviate
Copy link

dviate commented Dec 14, 2024

Since #5551 got closed and it's still not functioning as desired, here's a follow-up for this issue, which is bugging me in Kirby 4.5.0.


I was just playing around with this new feature, but apparently it doesn't work as expected as it brings the visitor to a 404 page. When I'm adding a link to another page, no matter in which language for a page I'm working, the current language is added to the a.

So, for instance, when I'm working in NL the HTML based on a UUID looks like <a href="/nl/@/page/HlyrsG30ZVPXPd9F">hallo</a> and when I'm working on a Spanish translation, it adds es to the URL so that it looks like <a href="/es/@/page/HlyrsG30ZVPXPd9F">hola</a>. The weird thing is, it works well in the non default language, but a UUID-based link that also contains the default language prefix, leads to a 404.

This HTML can also be found in the accompanying .txt file in the content folder; it appears that the link creator in the panel adds the country prefix to the URL which results in errors, since a link without a language prefix, like <a href="/@/page/HlyrsG30ZVPXPd9F">hello</a> works fine.

Not adding the language prefix via the panel when a user is editing something in the default language should do the trick here?

@distantnative
Copy link
Member

@dviate Please share your languages setup/config as well.

@dviate
Copy link
Author

dviate commented Jan 22, 2025

NL, in my test setup the main language:

<?php
return [
    'code' => 'nl',
    'default' => true,
    'direction' => 'ltr',
    'locale' => 'nl_NL',
    'name' => 'Nederlands',
    'url' => '/',
    'translations' => [

*etc*

ES, one of the test languages:

<?php
return [
    'code' => 'es',
    'default' => false,
    'direction' => 'ltr',
    'locale' => 'es_ES',
    'name' => 'Español',
    'url' => '/es',
    'translations' => [

*etc*

and just to make sure, also EN:

<?php
return [
    'code' => 'en',
    'default' => false,
    'direction' => 'ltr',
    'locale' => 'en_US',
    'name' => 'English',
    'url' => '/en',
    'translations' => [

*etc*

@distantnative distantnative added this to the 4.7.0 milestone Jan 23, 2025
@hansipete
Copy link

I'm having that problem as well. Want to share an easy workaround by adding a route to config.php

[
        'pattern' => '/de/@/page/(:all)',
        'action' => function ($uuid) {
            return go('page://' . $uuid);
        }
    ]

That maybe won't cover all cases but helped me for now.

@dviate
Copy link
Author

dviate commented Jan 24, 2025

This looks interesting as a temporary fix, @hansipete! This snippet is only meant to be used once, for the default language, in your case de (German)?

@hansipete
Copy link

Sorry, I never answered this one: Yes – in my case the default language is de and the configured url in config/languages/de.php is 'url' => '/'

I found that the language code is added to the link from the Writer Link Dialog:

permalink = "/" + window.panel.language.code + permalink;

The produced links will only work when the language url is identical to the language code?

@hotdoy
Copy link

hotdoy commented Feb 7, 2025

Same here!
Here's the config.

<?php

return [
    "code" => "fr",
    "default" => true,
    "direction" => "ltr",
    "locale" => [
        "LC_ALL" => "fr_CA"
    ],
    "name" => "Français",
    "url" => '/'
];

Currently I'm only seeing the issue with the Writer field (but that might be anecdotical).

@distantnative distantnative added the critical: roadblock 🚧 Needs to be solved first label Feb 7, 2025
@afbora afbora self-assigned this Feb 8, 2025
@afbora afbora linked a pull request Feb 8, 2025 that will close this issue
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
critical: roadblock 🚧 Needs to be solved first
Development

Successfully merging a pull request may close this issue.

5 participants