Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

copy page


Level 8

Hi All,


We've encountered a challenge regarding the utilization of a specific template. Previously, we had restricted the usage of the template exclusively to the path "/content/training(/.*)", using allowedpaths property.

Initially, we also permitted the path "/content/countrysites" within our allowed paths configuration. Consequently, certain pages were created under "/content/countrysites/en-us/aboutus".


However, subsequent adjustments led to the removal of "/content/countrysites" from the allowed paths. Presently, we encounter an issue wherein we intend to copy the page located at "/content/countrysites/en-us/aboutus" to "/content/countrysites/en-uk/aboutus". Regrettably, attempting to execute this operation results in an error message indicating that the template associated with the original page is not allowed under "/content/countrysites/en-uk".


Our objective is to copy the page from en-us to en-uk while ensuring that editors are unable to select the template for creating new pages. We seek guidance on achieving this objective within the constraints of our current configuration.







4 Replies


Level 4

Hi @Vani1012 , did you try adding the "/content/countrysites" to the allowed paths again after the removal and then try out the copy operation?


Level 8

Hi @kapil_rajoria Yes I tried that I am able to copy the page to en-uk but the problem is the editors are getting an option to create page under "/content/countrysites" with that article old template.

Here I want to restrict editors from creating pages using the old template while still allowing them to copy pages between different country sites.

1. From "/content/countrysites/en-us/aboutus" copy to "/content/countrysites/en-uk/aboutus"

2. From "/content/countrysites/en-us/contact" copy to "/content/countrysites/en-ca/contact"


Level 4

Hi @Vani1012 , to allow copying, it's necessary we should have "/content/countrysites" in allowed paths.
To restrict editors did you try to adjust the permissions to control which templates are visible to different user groups? If editors don't have read access to the old template, they won't be able to see or use it.

Also, the other ways could be:
-- Implement a custom validation step in a workflow that is triggered upon page creation. If the page is created with a disallowed template, the workflow step can either prevent further processing or notify an admin.
-- You can create a custom Sling filter/servlet/event listener that intercept requests for page creation and validate the template being used. If it's the old template, return a forbidden response or redirect to an error page.
-- Try deactivating the Old Template. I am not sure this would work or not though.
-- Customize the create page dialog using Granite UI components and use some logic to exclude the old template.


Level 8

Hi @Vani1012 ,

It sounds like you want to copy a page from one language region (en-us) to another (en-uk) within the /content/countrysites path, while still maintaining the restriction that editors cannot select the template for creating new pages.

Since you have restricted the usage of the template exclusively to the path "/content/training(/.*)", you need to ensure that this restriction does not prevent copying the page to the new location ("/content/countrysites/en-uk/aboutus").

To achieve this objective, you can follow these steps:

  1. Temporary Template Assignment: Temporarily assign a different template (one that is allowed in /content/countrysites/en-uk) to the page at "/content/countrysites/en-us/aboutus".

  2. Copy the Page: After assigning the temporary template, attempt to copy the page from "/content/countrysites/en-us/aboutus" to "/content/countrysites/en-uk/aboutus".

  3. Restore Original Template: Once the copy is completed, revert the template assignment of the copied page back to the original template (which is restricted to /content/training(/.*)).

By following these steps, you should be able to copy the page to the new location while ensuring that editors are unable to select the template for creating new pages. This approach allows you to temporarily bypass the template restriction during the copy operation.