SAP Commerce Cloud CMS page 和 page template 的概念

145 阅读1分钟

CMS pages are laid out according to their page template.

CMS 页面根据其template被布局。

在 SAP Commerce Accelerator项目里,一个page template包含下列内容:

  • A list of content slots predefined for the template. Template里预定义的content slot列表。
  • A FrontendTemplateName that corresponds to the name of a JSP that drives the layout of the page. 一个FrontendTemplateName,对应了一个同名的JSP文件,该文件负责定义页面的内容。
  • A list of PageTypes that the template is restricted to.

比如下图的含义,landing page 1 template只允许包含Content Page和Category Page.

  • A VelocityTemplate to specify the layout in SmartEdit.

如何定义一个新的page template

首先定义page template本身:

INSERT_UPDATE PageTemplate;$contentCV[unique=true];uid[unique=true];name;frontendTemplateName;restrictedPageTypes(code);active[default=true]
;;ContentPage2Template;Content Page 2 Template;layout/contentLayout2Page;ContentPage

然后定义content slot:

INSERT_UPDATE ContentSlotName;name[unique=true];template(uid,$contentCV)[unique=true][default='ContentPage2Template'];validComponentTypes(code)
;SiteLogo;;CMSImageComponent,BannerComponent
;HeaderLinks;;CMSLinkComponent,CMSParagraphComponent
;MiniCart;;MiniCartComponent
;NavigationBar;;NavigationComponent
;Section1;;$wideContent
;Section2;;$wideContent
;Section3;;$narrowContent
;Footer;;CMSLinkComponent,CMSParagraphComponent,FooterNavigationComponent

在impex的value区域我们并没有提供template信息,而是使用了默认的ContentPage2Template.

每个content slot都不是能够显示任何类型的Component,而是通过做了指定。比如,SiteLogo contentslot,只允许放置CMSImageComponent和BannerComponent.

Contentslot和page template的从属关系:

INSERT_UPDATE ContentSlotForTemplate;$contentCV;uid[unique=true];position[unique=true];pageTemplate(uid,$contentCV)[unique=true][default='ContentPage2Template'];contentSlot(uid,$contentCV)[unique=true];allowOverwrite
;;SiteLogo-ContentPage2;SiteLogo;;SiteLogoSlot;true
;;HomepageLink-ContentPage2;HomepageNavLink;;HomepageNavLinkSlot;true
;;NavigationBar-ContentPage2;NavigationBar;;NavigationBarSlot;true
;;MiniCart-ContentPage2;MiniCart;;MiniCartSlot;true
;;Footer-ContentPage2;Footer;;FooterSlot;true
;;HeaderLinks-ContentPage2;HeaderLinks;;HeaderLinksSlot;true

这个从属关系也能在Backoffice查看:

更多Jerry的原创文章,尽在:“汪子熙”: