Hi @prasanth_s
Yes, cross-conf reference is possible. You do not need to duplicate policies across your project folders.
AEM natively handles this through the Sling Configuration (Sling Conf) fallback mechanism. Because editable templates and policies use Context-Aware Configurations under the hood, AEM will automatically resolve global policies if they are mapped correctly.
Here is the approach to implement and maintain this.
How the Fallback Mechanism Works
When AEM looks for a policy (or any configuration) for a site that has cq:conf="/conf/myproject", it searches in a specific order:
-
/conf/myproject
-
/conf/global
-
/apps
-
/libs
If AEM does not find the mapped policy in /conf/myproject/settings/wcm/policies/..., it will automatically fall back and successfully retrieve it from /conf/global/settings/wcm/policies/....
Step-by-Step Approach
To map your common global policy to a site-specific template so the style icon appears in the editor, follow these steps via your codebase (CRXDE or your XML files):
1. Define the Global Policy Ensure your policy is stored in /conf/global.
2. Ensure No Local Overrides Make sure that the path /conf/myproject/settings/wcm/policies/my-commons/components/button/global-btn-policy does not exist. If it does, AEM will use it instead of the global one.
Important Caveats for Maintenance
-
Template Editor UI Behavior: If this is set up correctly via code, the paintbrush (Style) icon will show up in the page editor for authors. However, if an author goes into the Template Editor, opens the policy for that button, makes a change, and hits save, AEM may create a new localized node under /conf/myproject/.... This breaks the global inheritance for that specific tenant.
-
Codebase Enforcement: To maintain strict global governance, it is highly recommended to deploy these template policies configurations via your ui.content Git repository. This ensures that even if an author accidentally localizes a policy, your next deployment will align the environments back to the global setup.
-
Granular Permissions: If you want to strictly prevent authors from breaking this inheritance, consider restricting write access to the /conf/myproject/settings/wcm/policies path for template authors, forcing them to rely on the global configurations provided by the development team.