How to add a custom button that Duplicates a page?

Permalink
How do I duplicate a page with the current approved version using a custom button?

View Replies:
MrKDilkington replied on at Permalink Reply
MrKDilkington
Hi syedmushran,

Do you want this custom button in addition to the current methods of copying a page?

A page can be copied in the Sitemap and within the Versions menus.
syedmushran replied on at Permalink Reply
Hi MrKDilkington,

Yes, I would like to add this button to the CCM-Toolbar. I'm just trying to cut the down the steps to get to the existing options. I'm completely new to Concrete5 and have no idea on how to achieve this.

Appreciate your reply. Thanks!
daenu replied on at Permalink Reply
daenu
Hi
I'm affraid that this isn't possible without writing some code. Also is to note that the Page object is one of the largest in the system.

There is a method inside the Page Class:
// Get the page object
$page = Concrete\Core\Page::getByID(123);
// Get the collection for the page
$nc = Concrete\Core\Page\Collection::getByID($page->cID);
// Then duplicate
$page->duplicate($nc);
// Where $nc is the collection object for the page


To add a button to your toolbar you have to override the native toolbar in the application folder. BUT be very carefull when trying this! The page which is rendering the top toolbar is located here: /concrete/elements/page_controls_header.php