Is there any event when user copy the page?
Posted: Wed Oct 03, 2012 5:39 pm
Hi, i'm working on a module, and i need run some kind of code when user copy the page in cms made simple... Is there any event when this action is runing?
Content management as it is meant to be
https://forum.cmsmadesimple.org/
Code: Select all
$contentobj = $params['content'];
if ($contentobj->Id() == -1){ // It's a new page
// do somthing;
}
// make sure the new page is Active
if ($contentobj->Active() == 1) {
$_SESSION['mynewpage_active'] = 1;
}
Code: Select all
$content = $params['content'];
$contentops = ContentOperations::get_instance();
$content_id = $content->Id();
$contentobj = $contentops->LoadContentFromId($content_id);
if ($contentobj)
{
$hid = $contentobj->Hierarchy();
if (!$hid) {
// New pages are only partially saved. We need to set/get the hierarchy stuff
$contentops->SetHierarchyPosition($contentobj->Id());
$hid = $contentobj->Hierarchy();
}
$contentops->CreateFriendlyHierarchyPosition($hid);
// Ensure the newly created page is active
if (isset($_SESSION['mynewpage_active']) ) {
unset ($_SESSION['mynewpage_active']);
// do what you want with the new active page that has now been fully written to the db....
}