January 1, 2021
Estimated Post Reading Time ~

Policies in Editable templates

In this post, we will cover policies in Editable templates. With project-specific editable templates folder structure (created via configuration browser), we are done with "template-types" and "templates" (highlighted in green) and in this, project-specific policies will be stored under "policies" in the path -/conf/training/settings/wcm/policies



Policies:
  • Policies in Editable templates are similar to Design properties in the static template
  • Policies can be defined at the component level (properties or option that we see on "Policy" assign console is nothing but the properties/fields that we have as part of Design dialog of that particular component)
    • Layout container or parsys or specific components like title, image or any specific component for that matter, if it has design dialog (with some desired fields), the same would be rendered in "Policy" console
  • Policies can be defined for "base page component" (using which template type would have been created) using "Page Design".
Policy console:
  • Left side, under "Policy" we have the option to choose an existing policy or create a new policy via "+" or copy via an icon next to "+" by providing a suitable title and description for the policy.
  • Right side, under "Properties", what we see is the "Design Dialog" of a specific component. In the below screenshot, it is the Layout container component, where we can select allowed components for this container.


Location of Policies:
  • Policies defined like this are stored under the "policies" node of the project-specific template folder - in this case, /conf/training/settings/wcm/policies.
  • For a specific component, lets say if we configure a policy for layout container component, which is wcm/foundation/components/responsivegrid in template editor of "training" project, then the policy path would be /conf/training/settings/wcm/policies/wcm/foundation/components/responsivegrid/policy_xxxxx
    • where xxxx is a dynamically generated number and this policy_xxx node will have design properties.
  • Note: Understanding here is, design properties for a particular component would be saved in the path of that component under project-specific templates folder's policies path (provided design/policy being configured from that respective project's editable template editor.)
  • /conf/training/settings/wcm/policies/wcm/foundation/components/responsivegrid/policy_xxxxx
    • Green - project-specific templates folder's policies
    • Red - component path for which policy is configured
    • Blue - auto-generated policy name.
  • Page Design:
    • For assigning the policy to base page component, we have "Page Design" available under "Page information icon" in the toolbar of template editor (before Emulator icon)
    • Click on the same will open a "Policy console" where we will have the option to provide "clientlibraries" - Category name.
    • Page Design corresponds to the base page component using which we would have created template types and hence editable template.
    • Given this, path of the policy configured via "Page design" would be /conf/training/settings/wcm/policies/learnings/structure/components/structure/corepage/policy_xxx where base page component that I used for this is "learnings/structure/components/structure/corepage"
  • Policy Reference:
    • In general, how many ever editable templates that we have as part of our project, policies defined for all of those would be saved in one stop place under this path in the respective component path hierarchy - /conf/training/settings/wcm/templates/policies
    • Those individual editable templates will then have a reference to this generic placeholder policy location via a property named "cq:policy" in /conf/training/settings/wcm/templates/training-content-page/policies which would be automatically generated when we configure policy being in the particular editable template editor.
    • Important Note:
      • Not to get confused with "policies" under "/conf/training/settings/wcm/policies" and one under "/conf/training/settings/wcm/templates/training-content-page/policies",
      • former is a generic or one-stop placeholder for all the policies that we configure for a specific project (both individual components or via page design) and 
      • latter is holding the reference to those policies via a property named "cq:policy" with the value being the relative path to the policy.
    • (kind of indicating that particular editable templates' policies are residing under project-specific templates folder's policies definition)
    • Value of "cq:policy" being a relative path, it will first resolve to our project-specific templates folder's policies - /conf/training/settings/wcm/policies. If the same is not available, per the resource resolution strategy in this context, it will then fallback to /conf/global/.. -> then /apps/.. -> and then finally /libs/...
Screenshots :
  • In the editable template that we created - "training-content-page" from the "empty-page" template type, we have the Layout container alone now. We need to add a list of allowed components for this layout container via the "policies" icon (as highlighted below)


On click of policy icon -> defining policy for layout container. Have chosen "General" components group.


In CRXDE, the same would be saved as below:



Page Design:



On click of "Page Design":


In CRXDE, the above will be saved as:



Policy reference:


The policy defined via "Page design" will be referenced as shown below:


Other screenshots for reference:
"Other templates using selected policy section": Lists all the templates that use the same policy.
Right now we have only one template using this policy.


Below is to have a comparison of the policy console in Editable templates with "Design mode" in the static template.
Configure component option being in Design mode: (in a page created out of static template):


Policy in Editable template(given the understanding from the above design screenshot): Left-hand side(Policy title & description etc.) + Right-hand side (Design dialog of a specific component/what we see in pages created out of the static template in design mode)


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.