louisstephens Posted May 11, 2018 Share Posted May 11, 2018 I came across something today which has me a bit puzzled. I have a site structure like: Development - Dev Heading - Dev Parent - Dev Child - Dev Child - Dev Parent - Dev Child - Dev Child - Dev Heading - Dev Parent - Dev Child - Dev Child - Dev Parent - Dev Child - Dev Child If I copy/duplicate a page that has children (like Dev Heading or Dev Parent), I am taken to a screen to change the name/url as well as the url "slug". However, If I try to clone "Dev Child", it simply clones it as "Dev Child 1" and sets the status to unpublished. It is okay, but kind of annoying when the two have separate actions. Is there a setting to change the current behaviour, as I rather like being taken to a screen to directly edit/publish the page. This would be beneficial to me as I have a hook on after page save for certain templates, but currently it saves it everytime I try to copy "Dev Child", and then I have to go in and edit/publish the page. Link to comment Share on other sites More sharing options...
Robin S Posted May 11, 2018 Share Posted May 11, 2018 It's annoying, right? You could thumbs-up the existing request for a change to this behaviour: https://github.com/processwire/processwire-requests/issues/186 And as a workaround in the meantime try this hook in /site/ready.php: $wire->addHookAfter('ProcessPageListActions::getExtraActions', function(HookEvent $event) { $page = $event->arguments(0); $actions = $event->return; if(isset($actions['copy']['ajax'])) { unset($actions['copy']['ajax']); $actions['copy']['url'] = "{$this->config->urls->admin}page/clone/?id={$page->id}"; } $event->return = $actions; }); If you find it's not working for you then it might be getting called before the equivalent hook inside ProcessPageClone, in which case you could try experimenting with the "priority" option for hooks: https://processwire.com/api/ref/wire/add-hook-after/ 2 Link to comment Share on other sites More sharing options...
louisstephens Posted May 11, 2018 Author Share Posted May 11, 2018 Thanks Robin! I will definitely thumbs up the issue. Also, thank you for the work around, it works like a charm. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now