0

我尝试使用 Symfony CMF 在我们的 Web 应用程序上设置一个简单的 CMS。我可以成功加载多种语言的灯具。

$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');

我还可以在首页以正确的语言(当前语言环境)显示它们。

这是我的控制器动作:

public function pageAction(Request $request, $contentDocument) {
    return $this->render(':Frontend/CMS:index.html.twig', ['page' => $contentDocument]);
}

这是我的工作树枝文件:

{{ page.body }}

工作页面截图

但是一旦我尝试在我的页面上呈现菜单,它就会以默认语言显示文本。

{{ knp_menu_render('main') }}
{{ page.body }}

非工作页面的屏幕截图

菜单配置如下:

cmf_menu:
    persistence:
        phpcr:
            menu_basepath: /cms/pages

app.request.locale的输出总是fr。不管我是否包括菜单。

有谁知道什么可能导致这个问题?

4

0 回答 0