Problems, need help? Have a tip or advice? Post it here.
4 posts Page 1 of 1
Hi!
I use the addon copy-to-new to duplicate pages. The problem is that when I publish a copied page, it takes the creation date of the original page.
There is a way to have the duplicated page with the current date of creation?

Thank you!!
Hi,

I think you meant the 'publish' date - am I right in assuming that?
If so, the copied page is not automatically saved so one has the opportunity to tweak that date before saving the page.
Shouldn't be too much of a hassle.

I'd like to get the views of other users if they think auto-setting the cloned page's date to current date is indeed what should have been the default behavior.
KK wrote: Hi,

I think you meant the 'publish' date - am I right in assuming that?
If so, the copied page is not automatically saved so one has the opportunity to tweak that date before saving the page.
Shouldn't be too much of a hassle.

I'd like to get the views of other users if they think auto-setting the cloned page's date to current date is indeed what should have been the default behavior.


For me it would be the publish date.

I would be interested in knowing how to do this as I just had a client ask if I could make the date be the date it was copied as its technically a new page so they no longer have to open Advanced Settings and update the date field.

Not all my clients would like this however, it might be advantageous to have a setting in the copy-to-new/config.php so current users are unaffected with upgrades but others can enable if need be.

Something like:

Code: Select all
// Leave blank to stay retain page date. Enter 'new' as value to activate new date on copy
// $cfg['date'] = 'new';
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.

Attachments

4 posts Page 1 of 1