【问题标题】:Link a Static Page in Twig (Sylius)在 Twig (Sylius) 中链接静态页面
【发布时间】:2016-08-31 11:23:12
【问题描述】:

我使用的是最新的 Sylius,并在后端创建了一个静态页面。

内部名称是ueber-uns,我创建了一个链接到那里的路由。所以当我浏览mywebsite.com/ueber-uns 时,它可以工作。

现在我无法在我的 Twig 模板中为其生成路线。我唯一想到的是:

<a href="{{ path('sylius_static_content_show', {'path': 'uber-uns'}) }}">Über uns</a> 但这会引发

找不到路由“sylius_static_content_show””错误。

我在文档中找到的唯一页面是 emtpy:http://docs.sylius.org/en/latest/book/content.html?highlight=static

我还能在哪里找到相关信息?

【问题讨论】:

    标签: php symfony routing sylius


    【解决方案1】:

    尝试在路由的参数中使用name 而不是path

    <a href="{{ path('sylius_static_content_show', {'name': 'uber-uns'}) }}">Über uns</a>
    

    这是 ShopBundle 中的路由定义

    sylius_shop_static_content_show:
        path: /{name}
        methods: [GET]
        defaults:
            _controller: sylius.controller.static_content:showAction
            _sylius:
                template: SyliusShopBundle:StaticContent:show.html.twig
                repository:
                    method: findPublishedOneByName
                    arguments: [$name]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-08-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-04-03
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多