Rendering modes for web content | HCL Digital Experience
Different presentation templates are created to render web content in different modes to display content in different contexts, such as a web content viewer portlet, or mobile devices.
Render modes
These modes are supported when web content is rendered. You can create separate presentation templates for each type and select them when you create a site area template or content template:
- Default Presentation Template: This presentation template is used to render an item within a Web Content Viewer portlet.
- Summary Presentation Template: This presentation template is used when the summary render mode is used to render an item.
- JSON Record Presentation Template: This presentation template is used when the JSON render mode is used to render an item on mobile devices.
- XML Document Presentation Template: This presentation template is used when the XML render mode is used to render an item on mobile devices.
- HTML Document Presentation Template: This presentation template is used when the HTML render mode is used to render an item as a complete web page.
You then select a different presentation template for each rendering mode by clicking Select Presentation Template in the Item Properties section when you create a site area template or content template.
Defining rendering modes in a URL
You can specify a rendering mode in a URL by adding this parameter to the URL: renderMode=mode
These render modes are predefined: summary, json, xml, html, default. You can use the Web Content Manager API to define further render modes.
http://myserver:port/wps/wcm/myconnect/mylibrary/mysitearea/mycontent?renderMode=json
http://myserver:port/wps/wcm/myconnect/mylibrary/mysitearea/mycontent?renderMode=json,xml
http://myserver:port/wps/wcm/myconnect/mylibrary/mysitearea/mycontent?renderMode=json,default
Rendering modes for web content code sample
setPresentationTemplateForMode
to add a render mode to an
authoring template and map it to a presentation
template:authoringTemplate.getItemProperties().setPresentationTemplateForMode("YAML", defaultPresentationTemplateId);
The
example adds the render mode YAML to the authoring template specified by variable
authoringTemplate
and maps it to the presentation template specified by
variable defaultPresentationTemplateId
. Use the same method call to update
the presentation template mapping for an existing render mode YAML that was previously added
to the authoring template. After a new render mode is added to the template with the API,
the new mode is visible in the user interface when you edit the item. Users can update the
field and choose another presentation template from the user interface.authoringTemplate.getItemProperties().setPresentationTemplateForMode("YAML", null);
Use
the same method call to remove the currently mapped presentation template from an existing
YAML render mode.authoringTemplate.getItemProperties().removeRenderMode("YAML");
Create and remove a render mode
authoringTemplate.getItemProperties().setPresentationTemplateForMode("YAML", defaultPresentationTemplateId);
The
example adds the render mode YAML to the authoring template specified by variable
authoringTemplate
and maps it to the presentation template specified by
variable defaultPresentationTemplateId
.Use the same method call to update the presentation template mapping for an existing render mode YAML that has been previously added to the authoring template.
Once the new render mode is added to the template using the API, the new mode is visible in the UI when editing the item. Users can update the field and choose another presentation template from the UI.
authoringTemplate.getItemProperties().setPresentationTemplateForMode("YAML", null);
authoringTemplate.getItemProperties().removeRenderMode("YAML");