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

Force viewBag URLs #636

Closed
daftspunk opened this issue Apr 1, 2021 · 2 comments
Closed

Force viewBag URLs #636

daftspunk opened this issue Apr 1, 2021 · 2 comments

Comments

@daftspunk
Copy link
Member

@ivang76 As I understand it you have a single theme in a multisite environment that can have a different default locale per instance.

title = "NotizieTMP"
url = "/notizieTMP"
layout = "default"
is_hidden = 0
[viewBag]
localeTitle[it] = "Notizie"
localeTitle[en] = "News"
localeUrl[it] = "/notizie"
localeUrl[en] = "/news"
==
<?php ...

This makes the default URL somewhat redundant, however, it is always applied due to the logic of the default locale, which says "if locale is default, use the 'url' not the viewbag" but you want to force it to use the viewbag every time

As a workaround you've hacked the logic to always apply it

    if ($locale != $this->translatableDefault || true) {
        $localeUrl = $this->getSettingsUrlAttributeTranslated($locale) ?: $localeUrl;
    }

We could look at modifying the logic to simply check viewBag first always and use the URL as the fallback. This would solve the problem at minimal additional expense

@ivang76
Copy link

ivang76 commented Apr 1, 2021

ok perfect, thank you... in this way I think that also the localeTitle will follow the same logic, and not only the localeUrl, isn't it?

@ivang76
Copy link

ivang76 commented Apr 8, 2021

I write also here my actual solution to manage the title, just to keep note if maybe someone else need it...

function onEnd() {
    $this->page->title = $this->viewBag->localeTitle[App::getLocale()];
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants