Skip to content

Conversation

@giuscris
Copy link
Member

@giuscris giuscris commented Nov 9, 2025

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 giuscris added this to the 2.2.0 milestone Nov 9, 2025
@giuscris giuscris requested a review from Copilot November 9, 2025 18:30
@giuscris giuscris self-assigned this Nov 9, 2025
@giuscris giuscris added the enhancement New feature or request label Nov 9, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds functionality to duplicate pages in the panel. Users can now duplicate pages through a new modal dialog, which copies the page content and allows setting a new title and slug for the duplicate.

Key changes:

  • Added a duplicate page modal with title and slug fields
  • Added duplicate buttons to the page tree view and editor view with permission checks
  • Implemented backend duplication logic that copies page content and handles file operations

Reviewed Changes

Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
panel/views/pages/tree.php Adds duplicate modal registration and duplicate button in dropdown menu
panel/views/pages/editor.php Adds duplicate modal registration and restructures page actions into a dropdown menu containing duplicate and delete options
panel/translations/en.yaml Adds translation keys for duplicate page action and default title format
panel/src/ts/components/views/pages.ts Imports makeSlug utility and adds modal handler to pre-fill duplicate title/slug fields
panel/modals/duplicatePage.yaml Defines modal configuration with title and slug fields
panel/config/routes/routes.php Registers new route for duplicate action
panel/assets/icons/svg/duplicate.svg Adds duplicate icon SVG
formwork/src/Panel/Controllers/PagesController.php Implements duplicate controller action with validation and error handling
formwork/src/Pages/Page.php Adds isDuplicable() method, duplicate() method, and refactors save() to use new write() method

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sgirard84
Copy link
Contributor

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

@giuscris giuscris force-pushed the feature/duplicate-page branch from dfc35f1 to 262f21f Compare November 15, 2025 13:21
@giuscris giuscris marked this pull request as ready for review November 15, 2025 14:54
@giuscris giuscris requested a review from Copilot November 15, 2025 14:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@giuscris giuscris merged commit 7f2ccb0 into 2.x Nov 15, 2025
8 checks passed
@giuscris giuscris deleted the feature/duplicate-page branch November 15, 2025 15:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants