Expand my Community achievements bar.

Disable the move button for published pages and enable the move button for unpublished pages.

Avatar

Level 2

How do we disable the move button for published pages and enable the move button for unpublished pages,

This is in order to avoid the active pages being moved and the URL being changed. 

4 Replies

Avatar

Level 4

Are you not able to access the link? It's to a separate forum where the AEM experts hang out. That might be a better location for your question if you are trying to work with AEM pages. 

Avatar

Community Advisor

Hi @Nirmal_Kumar1 

You can try this solution and approach. 

1. Add Custom Property:

  • Add a custom property to pages to indicate their publish status. You can use a property like publishStatus with values like published and unpublished.

2. Customize the Page Properties Dialog:

  • Modify the dialog for the page properties to include the publishStatus field. This can be done using the AEM dialog editor.

3. Use Permissions:

  • Set up permissions so that different user groups have different access levels.
  • Define two groups: one for users who can publish and move pages, and another for users who can only move pages.
  • Users who can publish and move pages should have the permission to modify the publishStatus property.

4. Implement Client-Side Logic:

  • Use JavaScript to disable the "Move" button on the page based on the publishStatus property.
  • Create a client-side library in AEM that contains the JavaScript logic.
  • Include this library in your pages' templates or components.

 

$(document).ready(function() {
    var publishStatus = "${currentPage.publishStatus}"; // Get the value of the publishStatus property

    if (publishStatus === "published") {
        $("#cq-move").prop("disabled", true);
    } else {
        $("#cq-move").prop("disabled", false);
    }
});

 

 

5. Apply Customization:

  • Apply the customized dialog, permissions, and JavaScript logic to your AEM instance.

6. Test Thoroughly:

  • Test the solution thoroughly with both published and unpublished pages to ensure that the "Move" button behaves as expected based on the publish status.

7. Document Changes:

  • Document the changes you've made to your AEM project for future reference.

Remember that AEM environments can vary, and you might need to adapt the solution to match your specific AEM version and setup. Always test your customizations in a controlled environment before deploying them to a production instance.

Hope this information helps you !