DotCMS page API does not return "layout" field

92 views Asked by At

I want to use the Layout-as-a-Service (LaaS) feature of DotCMS. This approach is documented in https://dotcms.com/blog/post/more-than-a-headless-cms-layout-as-a-service-in-dotcms and also in https://github.com/fmontes/dotcms-page.

Both articles suggest, that the DotCMS page API should return a field called "layout" in the response, e.g. to http://localhost:8080/api/v1/page/json/test-page

test-page is a page, which is using a standard template. By standard template, I mean template created with "Template Designer", with a 20% sidebar on the left, one 100% width column, both containing "Blank container".

No matter what I try, the "layout" field is never part of the response. All I get is this:

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

I tried DotCMS version 5.2.0 and also 5.2.3. Is this perhaps a feature of the Enterprise edition only?

Edit: What I expect:

{
  "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
      }
    }
    ...
2

There are 2 answers

2
wezell On

Your page needs to use a "layout template" in order to retrieve the layout from dotCMS - using an advanced template won't work.

Also, layouts are part of the enterprise edition. Make sure you have a license in order to use the layout manager.

0
ygor On

Nevermind, I found the answer myself.

I checked the source code. In com.dotmarketing.portlets.htmlpageasset.business.render.page.HTMLPageAssetRenderedBuilder#build there is following piece of code:

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

So the answer is, that you can use LaaS promoted by DotCMS only if you have a non-community licence.