【问题标题】:DotCMS page API does not return "layout" fieldDotCMS 页面 API 不返回“布局”字段
【发布时间】:2020-02-19 19:14:39
【问题描述】:

我想使用 DotCMS 的布局即服务 (LaaS) 功能。这种方法记录在 https://dotcms.com/blog/post/more-than-a-headless-cms-layout-as-a-service-in-dotcms 还有 在https://github.com/fmontes/dotcms-page

两篇文章都建议,DotCMS 页面 API 应在响应中返回一个名为“布局”的字段,例如给http://localhost:8080/api/v1/page/json/test-page

test-page 是一个使用标准模板的页面。标准模板是指使用“模板设计器”创建的模板,左侧有一个 20% 的侧边栏,一个 100% 宽度的列,都包含“空白容器”。

无论我尝试什么,“布局”字段都不是响应的一部分。我得到的只是这个:

{
  "errors": [],
  "entity": {
    "canCreateTemplate": true,
    "containers": ...,
    "numberContents": 2,
    "page": ...,
    "site": ...,
    "template": ...,
    "viewAs": ...  },
  "messages": [],
  "i18nMessagesMap": {},
  "permissions": []
}

我尝试了 DotCMS 版本 5.2.0 和 5.2.3。 这可能只是企业版的一个功能吗?

编辑:我的期望:

{
  "errors": [],
  "entity": {
    "canCreateTemplate": true,
    "containers": ...,
    "layout": {
      "width": "responsive",
      "title": "mytemplate1",
      "header": true,
      "footer": true,
      "body": {
        "rows": [
          {
            "columns": [
              {
                "containers": [
                  {
                    "identifier": "b5ea1513-7653-4602-a729-97cd8dd099b6",
                    "uuid": "1582123997023"
                  }
                ],
                "widthPercent": 100,
                "leftOffset": 1,
                "styleClass": null,
                "preview": false,
                "width": 12,
                "left": 0
              }
            ],
            "styleClass": null
          }
        ]
      },
      "sidebar": {
        "containers": [
          {
            "identifier": "b5ea1513-7653-4602-a729-97cd8dd099b6",
            "uuid": "1582123991866"
          }
        ],
        "location": "left",
        "width": "small",
        "widthPercent": 20,
        "preview": false
      }
    }
    ...

【问题讨论】:

    标签: dotcms


    【解决方案1】:

    没关系,我自己找到了答案。

    我检查了源代码。在com.dotmarketing.portlets.htmlpageasset.business.render.page.HTMLPageAssetRenderedBuilder#build 中有以下代码:

            final TemplateLayout layout = template != null && template.isDrawed() && !LicenseManager.getInstance().isCommunity()
                    ? DotTemplateTool.themeLayout(template.getInode()) : null;
    

    所以答案是,只有拥有非社区许可证才能使用 DotCMS 推广的 LaaS。

    【讨论】:

      【解决方案2】:

      您的页面需要使用“布局模板”才能从 dotCMS 检索布局 - 无法使用高级模板。

      此外,布局是企业版的一部分。确保您拥有许可证才能使用布局管理器。

      【讨论】:

      • 我明确声明,我的页面没有使用高级模板。它使用标准模板,使用模板设计器构建,即使没有许可证也可以使用该功能。
      • 同时,我通过企业许可证访问了一个 DotCMS 网站。我使用相同的模板创建了完全相同的页面,并且页面 REST API 在响应中返回布局。但是相同的 REST API 不会返回我本地(免许可)安装的 DotCMS 的布局。没有许可证有区别吗?
      猜你喜欢
      • 2013-08-17
      • 2017-09-26
      • 2018-11-18
      • 1970-01-01
      • 1970-01-01
      • 2021-07-13
      • 2012-08-24
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多