You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CMS pages do not provide the localized version of the page title when accessing {{ this.page.title }} or $this->page->title unless I have the /[locale]/ prefix in my URL.
My page configs look like this:
....stuff
title = "Title in default locale"
....more stuff
[viewBag]
localeTitle[en] = "Title in alternative locale"
When relying on the locale stored in the session, it always displays the page title in the default locale.
A possible workaround is to override the page title by putting the following code in a component and placing it in your page/layout:
public function onRun()
{
if ( ! $this->page->page instanceof \Cms\Classes\Page) {
return;
}
$locale = app('translator')->getLocale();
if ($this->page->localeTitle && array_key_exists($locale, (array)$this->page->localeTitle)) {
$this->page->title = $this->page->localeTitle[$locale];
}
}
The text was updated successfully, but these errors were encountered:
guus-frenken
changed the title
CMS pages do not show localizedTitle unless the locale prefix is present in the URL
CMS pages do not show localeTitle unless the locale prefix is present in the URL
May 17, 2022
I have confirmed this is no longer an issue using the latest codebase versions (OCMS v3 and Translate v2). It was likely fixed as part of the rewrite, along with a bunch of other issues.
The title is rendered with the following and is translated based on the selected site:
CMS pages do not provide the localized version of the page title when accessing
{{ this.page.title }}
or$this->page->title
unless I have the /[locale]/ prefix in my URL.My page configs look like this:
When relying on the locale stored in the session, it always displays the page title in the default locale.
A possible workaround is to override the page title by putting the following code in a component and placing it in your page/layout:
The text was updated successfully, but these errors were encountered: