formwork icon indicating copy to clipboard operation
formwork copied to clipboard

Add the possibility to duplicate pages

Open giuscris opened this issue 2 months ago • 1 comments

This pull request adds a "Duplicate Page" feature to the CMS, allowing users to create a copy of an existing page through the panel UI. The implementation includes backend logic for duplicating a page, frontend modal integration, new route and permissions checks, and UI updates to expose the feature in both the page editor and the page tree.

The most important changes are:

Backend functionality:

  • Added isDuplicable() and duplicate() methods to the Page class, enabling logic to check if a page can be duplicated and to perform the duplication, including copying content and updating fields like slug and title. [1] [2] [3]
  • Added a new controller action duplicate in PagesController to handle the duplication request, validate input, and redirect the user to the new page's editor. Also added a helper method duplicatePage for the duplication process and content history update. [1] [2]
  • Registered a new POST route panel.pages.duplicate for the duplication endpoint.

Frontend and UI integration:

  • Added a new modal definition duplicatePage.yaml for collecting title and slug when duplicating a page.
  • Updated the page editor and page tree views to include a "Duplicate Page" option in the actions dropdown, with permission checks and disabled state if the page is not duplicable. [1] [2]
  • Registered the duplicate page modal in relevant views. [1] [2]

Frontend logic:

  • Updated the TypeScript pages.ts component to handle opening the duplicate modal, pre-filling the title and slug fields using the original page title, and generating a slug automatically. [1] [2] [3]

Localization:

  • Added new translation strings for the duplicate page feature.

giuscris avatar Nov 09 '25 18:11 giuscris

You are on a roll with all these PR recently :) And I see you started some work with plugins too.. That's really exciting! Thank for this great CMS

sgirard84 avatar Nov 09 '25 18:11 sgirard84