The adaptive template rendering provides a way to manage a page with variations. Originally useful to deliver various HTML output for mobile devices (e.g. feature phone vs. smart phone), this feature is useful when experiences have to be delivered to various devices that need different markup or HTML output.
Templates are generally built around a responsive grid, and pages created based on these templates are fully responsive, adjusting automatically to the viewport of the client device. Using the Emulator toolbar in the page editor, authors can target layouts to specific devices.
It is also possible to set up templates to support adaptive rendering. When device groups are properly configured, the page will be rendered with a different selector in the URL when selecting a device in the emulator mode. Using a selector a specific page rendering can be directly called via the URL.
Remember when setting up your device groups:
- Every device must be in at least one device group.
- A device can be in multiple device groups.
- Because devices can be in multiple device groups, selectors can be combined.
- The combination of selectors is evaluated top-to-bottom as they are persisted in the repository.
The device group Responsive Devices will never have a selector because devices that are recognized as supporting responsive design are assumed to not need an adaptive layout
Adaptive rendering selectors can be configured for existing device groups or to groups that you have created yourself.
For this example, we are going to configure the existing device group Smart Phones to have an adaptive rendering selector as part of the Experience Page template within We.Retail.
Using CRX DE Lite, allow the device group to be used on your template by adding it to the multi-value string property cq:deviceGroups on the structure of your template.
For example, if we wish to add the Smart Phone device group:
Now when using the emulator in the page editor (such as when modifying the layout) and you choose a device of the configured device group, the page will be rendered with a selector as part of the URL.
In our example, when editing a page based on the Experience Page template, and choosing iPhone 4 in the emulator, the page is rendered including the selector as arctic-surfing-in-lofoten.smart.html instead of arctic-surfing-in-lofoten.html
The page can also be called directly using this selector.