I needed to get this adjustment made for my client as when they duplicate pages there is no need to keep the original page date and they had to change it every time to todays date and time which was cumbersome.
Today I worked on adjusting the add-on and I was able to accomplish the functionality of setting the publish date to today's date instead of retaining the date of the original page being copied.
It probably isn't the best way and hopefully KK is able to update the add-on with a toggle switch in the copy-to-new config file but it's a way that worked for me and my client is happy.
I placed a
$ctn_toggle true/false variable at the top in couch/config.php on line 5:
- Code: Select all
$ctn_toggle = true; // set false to retain original copy-to-new addon publish_date functionality, set to true to use today's date.
Then on line 31 of copy-to-new/edit-copy-to-new.php update the global code:
- Code: Select all
global $FUNCS, $DB, $PAGE, $CTX;
to the following, adding
$ctn_toggle variable to the end of the global.
- Code: Select all
global $FUNCS, $DB, $PAGE, $CTX, $ctn_toggle;
Next, above the following code on line 64 of copy-to-new/edit-copy-to-new.php:
- Code: Select all
unset( $f );
Add the following code:
- Code: Select all
if( $ctn_toggle && $f->name=='k_publish_date' ){
$f->data=date('Y-m-d H:i:s', time());
}
It should look like this when done:
- Code: Select all
for( $x=0; $x<count($pg->fields); $x++ ){
$f = &$pg->fields[$x];
$f->page_id = $pg->id;
$f->modified = 1;
if( $f->name=='k_page_name' ){
$f->data='';
}
if( $ctn_toggle && $f->name=='k_publish_date' ){
$f->data=date('Y-m-d H:i:s', time());
}
unset( $f );
}
For those who wish to update their add-on, please complete the steps above.
Maybe this will help others.

I also attached the modified copy-to-new/edit-copy-to-new.php and couch/config.php to this post as examples.