Beginners Tutorial: Reuse Editable Template With Multiple Sites - Adobe Experience Manager(AEM)
Вставка
- Опубліковано 7 вер 2024
- #aem #aemdeveloper #adobeexperiencemanager
Beginners Tutorial: AEM arch type UI Front End Module | Multi Tenancy Theme Support- • Beginners Tutorial: AE...
Demo Project - github.com/tec...
Editable templates have been introduced in AEM 6.2, which allows the authors to create and edit the templates instead developers creating managing the templates. Template authors can create and configure templates from the Templates console in the AEM without the help of the development team. Template authors can define the policies, structure, and initial content for the templates that will be shared by all the pages created based on this template.
Before editable templates, the developers create and manage the template called as static template for different structure variation and the authors use the templates to create the pages.
Even the template-authors can configure the client libraries - CSS/JS need to be applied for this template through template policy
Most of the time we will have a generic template enabled with headers and footers through experience fragment and the container with allowed components that can be managed by Authors while creating the pages
This will have some constraint while reusing the template with multiple sites
site-specific header and footer -- customize the header/footer for individual website
site-specific style/theme -- enable different styles/themes for individual sites.
let us now see the approach to enable the editable template with multiple sites that have the different header/footer and styling requirements.
site-specific header/footer:
Most of the time the header and footer are enabled through experience fragment and configured in template level by using experience fragment component so that all pages created based on this template will have the consistent header/footer experience.
The issue is while reusing the template with sites that require a localized header and footer, the Experience Fragment core component saves us here, the Experience Fragment core component enables the support for localized fragment content
If the experience fragments and the sites follow the same localized structure, the experience fragment core component uses the localized fragment content based on the site language.
site-specific style/theme
Most of the time we may have the need to enable site-specific style/theme for the websites that are built on the same templates. By default Editable template and core components won't support different styles for the websites built on the same template - the client libraries are enabled either in the page rendering component or in the template. The cq:designPath value configured in the site property will not be honored by editable templates and core components, the cq:designPath is more used by the static template.
Let us see a custom approach that will help us to enable site-specific style/themes(client library).
The front end module should generate the site-specific client library that can be configured for individual website, refer to the below link for the details on enabling site-specific client libraries through the UI frontend module.
The above front end module generates the site-specific client library in the following format
- site name.site e.g. site1.site, site2.site
- site name.dependencies e.g site1.dependencies, site2.dependencies
As a first step enable the additional property- styleName to the page dialog (if required enable dropdown list with predefined style values, also the property can be enabled in all level to apply different site and page level styles) -- the styleName value is equal to the site names used by ui frontend module e.g site1, site2 (use context-aware configuration instead of page properties if required)
Enable sling model to to return the site specific client library names based on the inherited styleName property passed from customheaderlibs.html and customfooterlibs.html files of the page rendering component.
Enable the client library categories into the page rendering component - customheaderlibs.html and customfooterlibs.html, the inherited style name property is injected to StyleNameModel - the property form current page if not available then from the parent hierarchy
Remove the client library configurations from template policy and enable the required style name to the site root or individual pages
Now the site-specific style is applied based on the configuration, the style to the page is applied in the following order
-- Apply the style name from the current page
-- Apply the style name from any of the available parent page (navigated till root node)
-- the default style is applied if no style name is configured for the current page or to the parent hierarchy.
The default style is applied while editing the pages through the template editor -- the structure and initial content.
Excellent video, thanks for sharing
Very helpful.
Please make a video on aem dispatcher set up in local
Does this localization feature for XF works on AEM 6.4.+ ? Or it more dependent on the version of the core components package.