Jump to content
adrian

Copy/clone page created/modified dates

Recommended Posts

The current behavior is that the created and modified dates are brought across to the new page, but I wonder if this is expected / desired behavior. For my current use, I'd prefer they weren't but before submitting an issue I'd like to know what others think.

Thanks!

  • Like 1

Share this post


Link to post
Share on other sites

Never really thought about that detail but in terms of naming...

Clone = I'd expect the same created/modified dates

Copy = I wouldn't be shocked if those dates would be different

 

An option in the module settings to change the behaviour could be nice - at least in your case. I can't really remember a situation in which I used those date. I almost always rely on additional date fields.

 

  • Like 2

Share this post


Link to post
Share on other sites

Thanks for your thoughts @wbmnfktr - it's actually weird to me that the core module is called "Clone" but the page list action button is called "Copy".

I kind of agree with clone having the same dates because a clone should be identical, but I also don't think that in reality anyone actually wants a clone in the end - usually it's just a quick way to start a new page from existing content and modifying it to your needs after that. 

An option for changing the behavior might be a decent approach to the problem.

Anyone else have any thoughts?

I think in reality I'll probably end up hooking into ___clone or ___cloned and adjust "created" via SQL (or the quite save option) because I don't honestly see that Ryan will want to change the current behavior.

 

  • Like 3

Share this post


Link to post
Share on other sites
34 minutes ago, adrian said:

I think in reality I'll probably end up hooking into ___clone or ___cloned and adjust "created" via SQL (or the quite save option) because I don't honestly see that Ryan will want to change the current behavior.

When done, please share ( you always do that anyway 🙂 ) 

Share this post


Link to post
Share on other sites

This works:

$this->addHookAfter('Pages::cloned', function(HookEvent $event) {
    $p = $event->arguments(1);
    $p->created = time();
    $p->save(array('quiet' => true));
});

This doesn't handle "modified", but for my needs I don't need that because publishing the newly cloned page will adjust that automatically then. But, if you do, you could add this to the hook:

$sql = "UPDATE `pages` SET `modified` = NOW() WHERE `id` = '".$p->id."';";
$this->wire('db')->query($sql);

 

  • Like 3
  • Thanks 1

Share this post


Link to post
Share on other sites
On 5/11/2019 at 6:19 AM, adrian said:

For my current use, I'd prefer they weren't but before submitting an issue I'd like to know what others think.

I've never needed to use ProcessPageClone but I would have expected the created/modified time to be set to the time the new page is cloned from the old page. Maybe there are use cases for cloning the created/modified times, so perhaps the issue could be a feature request for the option to determine what happens to created/modified times on the cloned page?

  • Like 1

Share this post


Link to post
Share on other sites
12 minutes ago, Robin S said:

I would have expected the created/modified time to be set to the time the new page is cloned from the old page

Yeah, me too 🙂

Share this post


Link to post
Share on other sites
13 hours ago, Robin S said:

I would have expected the created/modified time to be set to the time the new page is cloned from the old page.

Same here.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...