Page model
Overview
A WebCmsPage
is a component that represents a single page in the application.
It differs from an article>in that the page is stand-alone, i.e. you have more control regarding the layout and the components of the page.
One can use this, for example, to create about or faq pages.
It is related to the publication model in that an article is contained in a page: the data is contained in the article component, but how the article is rendered is handled by the page.
Properties
Name | Type | Mandatory | Description | Default Value |
---|---|---|---|---|
Page Type |
Yes |
Defines the page type of a page. Can be set during page creation but can not be changed afterwards. |
Default |
|
Title |
String |
Yes |
The title of the page. |
None |
Parent |
Select |
No |
Parent page of the page. Affects any generated URLs and (if auto-generated) the canonical path. |
None |
Template |
String |
No |
The thymeleaf template of the page. The filename of the page without the extension. If none is defined the one from the page type is used. |
None |
Path Segment |
String |
No |
The path segment of the page. |
None |
Auto create menu items |
Checklist of menu names. |
No |
If checked, a menu item is generated for the checked menu(s). |
None |
There are two configurable subsections, one for URL settings and one for publication settings
URL settings
Field | Type | Mandatory | Description | Default Value |
---|---|---|---|---|
Path Segment |
String |
Yes |
Path (URL) of the page. |
None |
Canonical path |
String |
Yes |
FQDN of the page. Must be unique within the application. |
None |
Both of these can be generated manually or automatically, depending on the title and parent (and grandparent, and …) of the page by checking the relevant checkboxes.
Publish settings
Field | Type | Mandatory | Description | Default Value |
---|---|---|---|---|
Published |
Boolean |
Yes |
If the page is published (or not). Published pages are visible for regular, non-logged in users. |
None |
Publication Date |
Date |
No |
The page is only visible if the access date of the file is greater than the publication date. |
None |
Auto-create new menu items |
Boolean |
Yes |
If checked, creates a new menu item after creation. |
False |
When creating or updating the page, the following updates are done with regards to the associated URLs:
-
If the page object is saved, and the publication is in the future or not yet published, update the primary url.
-
If the page object is saved and published but the publication date is in the past, no adjustments to the primary url will happen.
This, however, can be overridden by behaviour defined in WebCmsMenu
.
Page template
A page can optionally specify a template that should be used for rendering.
If the template is left empty, the template
attribute of the WebCmsPageType
will be used as template for rendering instead.
If the WebCmsPageType
does not specify a template either, the value of module setting webCmsModule.pages.default-template
will be used.
A page template will usually be resolved by the configured Spring MVC ViewResolver
beans.
By default page templates are expected to be Thymeleaf template files.
At startup of the application, WebCmsModule will attempt to determine the default template path of the current application. Any relative template will then be automatically prefixed with the default template path. Only templates with a specified prefix (eg. th/) are considered absolute and will be left untouched.
The default file extension .html does not need to be specified when setting the template value.
Example:
MyApplication
would resolve the default template path as th/my/
.
-
template
my-template
would be resolved asth/my/template
-
template
th/other-module/my-template
would be resolved asth/other-module/my-template
You can manually specify the default template prefix using property webCmsModule.pages.template-prefix .
See the module settings for all options you can configure if you want to change the default template resolving behaviour.
|
Web Components
A WebCmsPage
can contain different WebCmsComponent
assets.
Those form the building blocks of the pages.
For further information, please check the chapters on components.
URLs
A WebCmsPage
can be referred to by different URLs. Please see the respective chapter for more information.
Importing a page
One can import a page by using the import infrastructure provided by the import functionality of WebCmsModule.
Examples
Example page
page:
- title: Always Created Page (1)
- objectId: "wcm:asset:page:reference-simple"
title: Simple Page
- objectId: "wcm:asset:page:reference-simple-child"
title: Simple Child Page
parent: "wcm:asset:page:reference-simple" (2)
published: true
- objectId: "wcm:asset:page:reference-fixed-path-segment"
title: Fixed Path Segment Page
parent: /simple-page (2)
pathSegment: fixed
publicationDate: "2017-03-14"
- objectId: "wcm:asset:page:reference-faq"
title: Frequently Asked Questions
pathSegment: faq
wcm:menu-items: (3)
- menu: sideNav
- menu: topNav
title: FAQ
path: /help/faq
sortIndex: 10
1 | Sensible defaults are used. Only title is mandatory. |
2 | One can refer to both the object id and the canonical path. |
3 | You can use this notation to manipulate the associated menu items. |
Properties
Page properties that can be imported
Property | On UI | Details |
---|---|---|
title |
Title |
|
parent |
Parent |
Should be the canonical path or the objectId |
pathSegment |
Path segment |
|
pathSegmentGenerated |
Generate path segment based on title |
|
canonicalPath |
Canonical Path |
|
canonicalPathGenerated |
Generate canonical path based on title |
|
template |
Template |
|
pageType |
Page type |
Only supported during creation; if you do an update where the type has been changed an exception will be thrown. |
objectId |
- |
|
isPublished |
Published |
|
publicationDate |
Publication Date |
WebCmsPageType
A WebCmsPageType is used for assigning a certain type of page to a WebCmsPage. The default page type is controlled via the webCmsModule.pages.default-page-type
parameter in the configuration.
Properties
Field | Required | Type | Description | Default Value |
---|---|---|---|---|
Name |
Yes |
String |
The name of the page type. Displayed in the drop down list when creating a new page. |
None |
Attributes |
No |
The attributes affecting the behaviour when rendering/creating the page. Specified as key-value pairs. |
None |
|
wcm:components |
No |
Components |
The components that are automatically generated when creating a page that uses this page type. |
None |
Attribute | Description |
---|---|
contentTemplate |
The name of the container component whose components should be cloned to every page of that type. If omitted, a component called contentTemplate will be searched for. |
defaultTemplate |
The thymeleaf page that is used if there has not been a page specified on the page itself. |
hasEndpoint |
Whether or not an endpoint is defined for a page. If you disable this, the menu and URL functionality will be disabled on the front end. |
isPublishable |
Whether or not the page can be published. |
Importing a page type
In the standard setup one can only manipulate the available page types via the import functionality. The default types are described further down. One can extrapolate any other needed page type from them.
Default page types
types:
page:
default: (1)
name: Default
template:
name: Template
attributes: (2)
hasEndpoint: false
isPublishable: false
1 | The default page type. Notice that there are no attributes, so the default attributes specified are in effect for this type. |
2 | Attributes are defined as simple key-value pairs. |
Another, more complex example. This page contains multiple nested containers that themselves have child components.
Tabbed
tabbed-page:
name: Tabbed page
attributes:
template: th/cfr/tabbed-page
wcm:components:
content:
componentType: container
sortIndex: 1
wcm:components:
code:
title: Code
componentType: container
wcm:components:
introduction:
title: introduction
componentType: html
sortIndex: 1 (2)
content: | (1)
<section>introduction</section>
requirements:
title: requirements
componentType: html
sortIndex: 2
content: | (1)
<section>requirements</section>
browser-support:
title: browser support
componentType: html
sortIndex: 3
content: | (1)
<section>browser support</section>
further-reading:
title: further reading
componentType: html
sortIndex: 4
content: | (1)
<section>further reading</section>
documentation:
title: Documentation
componentType: html
sortIndex: 2
used-in:
title: Used in
componentType: html
sortIndex: 3
1 | Pre-filled content. When a page is created using this template, this data will be filled in (but can be changed by the user). |
2 | You need to manually set the sort order, or otherwise the default value (i.e. 0) will be filled in. |
Web infrastructure
Any WebCmsPage
will automatically create a WebCmsAssetEndpoint
with generated URL values.
Default page controller model
When requesting a page endpoint a default model will be rendered:
-
the template rendered will be determined by the
template
property or by theWebCmsPageType
if notemplate
is set on the page itself -
the components attached to the page will be available as page scope
-
the following model attributes will be registered:
-
page:
WebCmsPage
being rendered -
asset:
WebCmsPage
being rendered (alias for page)
-
The default page model is loaded by the WebCmsPageModelLoader
bean.
Custom page mapping
You can create your own page handler by using @WebCmsPageMapping
annotation.
The @WebCmsPageMapping
annotation can be combined with other @RequestMapping
annotations to create a specific match.
@WebCmsPageMapping(canonicalPath = "/my/page") (1)
public void extendSpecificPageModel( WebCmsPage page, Model model ) {
model.addAttribute( "extraData", ... );
}
@GetMapping (2)
@WebCmsPageMapping(pageType = "static") (2)
@IgnoreEndpointModel (3)
public String renderStaticPage( WebCmsPage page, Model model ) {
model.addAttribute( "page", page );
return "th/my-app/static-page";
}
1 | Handler method that will be used for the single page with the unique canonicalPath /my/page. The default page model will still be loaded, this handler only adds a model attribute. This handler method could optionally return a view, but since it does not, the view being rendered is still determined by the default model. |
2 | Handler method for a page of type static, provided the page is requested using the HTTP GET method. |
3 | The @IgnoreEndpointModel annotation suppresses the default page model from being loaded.
The handler method should fully initialize the model required as well as return the view that should be rendered. |