【问题标题】:Bolt CMS: Route no match, try next routeBolt CMS:路线不匹配,尝试下一条路线
【发布时间】:2017-02-13 12:29:23
【问题描述】:

我有两种内容类型,但我不希望 URL 中的内容类型 slug。所以这两种内容类型都应该匹配/{slug},但从不同的内容类型中获取内容。

不过,我创建了两条路线,如果第一条失败,它会尝试第二条:

# match on any landingpage created as a contenttype landingpage
landingpagebinding:
    path: /{slug}
    defaults:
        _controller: controller.frontend:record
        contenttypeslug: landingpage
    contenttype: landingpage

# match on any actionpage created as a contenttype actionpage
actionpagebinding:
    path: /{slug}
    defaults:
        _controller: controller.frontend:record
        contenttypeslug: actionpage
    contenttype: actionpage

所以我有:

  • 登陆页面“/this-is-my-landingspage”
  • 一个操作页面“/this-is-my-actionpage”

登录页面正常,操作页面出现 404 错误

未找到登陆页面/this-is-my-actionpage。

为什么我在landingpagebinding 上收到 404?我预计它会继续下一条路线,actionpagebinding 并尝试与之匹配。如果也没有找到,那么我想要一个 404 错误!

注意:我知道当两个内容类型具有相同的 slug 时,第一个会匹配。但这不是问题。

【问题讨论】:

    标签: url-routing bolt-cms


    【解决方案1】:

    我遇到了同样的问题。如果没有找到之前的 slug,您将不得不编写一个函数来获取下一个 slug。

    bolt 所做的只是检查第一个选项然后停止。您必须编写一些函数,让它继续读取,直到找到想要的文件。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多