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