I try to set up a simple CMS on our web application using the Symfony CMF. I can successfully load the fixtures in multiple languages.
$parent = $dm->find(null, '/cms/pages');
$rootPage = new Page(array('add_locale_pattern' => true));
$rootPage->setTitle('main');
$rootPage->setParentDocument($parent);
$rootPage->setName('main');
$rootPage->setBody('');
$dm->persist($rootPage);
$aboutPage = new Page(array('add_locale_pattern' => true));
$aboutPage->setTitle('About');
$aboutPage->setParentDocument($rootPage);
$aboutPage->setBody('About us DE');
$aboutPage->setName('about');
$aboutPage->setLabel('About');
$dm->persist($aboutPage);
$dm->bindTranslation($aboutPage, 'de');
$aboutPage->setBody('About us FR');
$aboutPage->setLabel('About FR');
$dm->bindTranslation($aboutPage, 'fr');
I can also display them in the right language (current locale) on the front page.
This is my controller action:
public function pageAction(Request $request, $contentDocument) {
return $this->render(':Frontend/CMS:index.html.twig', ['page' => $contentDocument]);
}
And this is my working twig File:
{{ page.body }}
Screenshot of the working page
But as soon as I try to render a menu on my page, it will show the text in the default language.
{{ knp_menu_render('main') }}
{{ page.body }}
Screenshot of the non working page
The menu is configured as follow:
cmf_menu:
persistence:
phpcr:
menu_basepath: /cms/pages
The output of app.request.locale is always fr. No matter if I include the menu or not.
Does anyone have an idea what could cause this problem?