Jump to content

Clone/Copy pages from the admin ?


jbroussia
 Share

Recommended Posts

Hi,

After discussing the options for multilingual sites (http://processwire.com/talk/index.php/topic,259.0.html, sorry for using the News & Announcements section for that !), I'm now evaluating the possibility to use the "tree" method...

One of the first things that come to my mind is that, for using such a method it would be nice to be able to quickly clone/copy a page from one tree to another. What I mean is that there could be new link after the existing edit/view/new/move ones, named copy (or clone) to be able to drag/drop a copy of any page, instead of moving it.

So the fields would already be set up and filled with data, all that remains is the need to translate the content...

Link to comment
Share on other sites

I agree that we need a good page clone/copy module of some sort. I'm conflicted as to whether this should be a Process of it's own (a separate add-on tool), an option in the PageList like "edit | new | move | copy", or an option on the 'add page' screen. In PW1, it was accomplished with a separate tool (see attached screenshot).

For your particular need, another good option might be to create a module that hooks to $pages->save and creates the copy automatically where you want it, when it detects that it's a page that should have multi-language versions. I'll be happy to guide you through creating this if you are interested.

post-1-132614278484_thumb.png

Link to comment
Share on other sites

What's neat with the "move" functionality is that you can move *branches* of the tree: pages and their subpages will be moved. That would be great for a copy function ! From your screenshot it doesn't seem like it was possible with PW1 ?

Concerning your proposal, I don't want to bother you with that (for now :-p)... but just to know, how would you detect that a page needs to be translated in multiple languages ?  ??? And as someone pointed in the previous conversation, there may be cases where some pages will be different from one language to another, local news for example, so maybe manual cloning would be better than automatic ?

Link to comment
Share on other sites

The way you'd detect it would be for the hook to see if the template or parent is one of the ones you are maintaining multiple languages for. When a page is added, it would check the other language trees to see if it also needed to create another page of the same name in those other trees. I think the implementation would be fairly straightforward. But manual cloning makes no assumptions so if there will be plenty of exceptions where you don't want things to be the same across the trees, then manual cloning probably can't be beat.

A copy/clone that does an entire tree would certainly be convenient. Whatever solution we end up going with, we'll make it recursive (or at least have the option) so that it can also clone children and so on.

Link to comment
Share on other sites

Oh I just understood that copying is not as easy as it seems, I made the assumption that the move was doing a copy/delete like in a file system, but I now realize that the move is probably just a change of parent ID in the DB. Copying implies a lot more work.

Link to comment
Share on other sites

You are right about how the move works. Just a change of parent_id (and a cache clear). It doesn't mean that a copy is particularly hard, just that it'll involve a lot more overhead than a simple move.

Link to comment
Share on other sites

  • 1 year later...
  • 3 months later...

Was this taken any further as I am interested in how to clone/copy pages?

Sorry, I have just found the module for this here.

I'm also working on a project where I need cloning and I installed ProcessPageClone.module to do this.

When I try to clone one (and only) product page I receive error:

TemplateFile: Duplicate entry 'demotuote-1-1017' for key 'name1010_parent_id' INSERT INTO pages SET parent_id=1017, templates_id=46, name='demo-product-1-1', modified_users_id=41, status=1, sort=0,modified=NOW(), name1010='demotuote-1', name1011=NULL, created=NOW(), created_users_id=41

It seems to bug about duplicate entry for finnish name so is this module compatible with Multilanguage Page Names?

Default language is english and name field for existing page is set to demo-product-1 (demotuote-1 in finnish translation).

Link to comment
Share on other sites

The ProcessPageClone module is not yet updated for use with the LanguageSupportPageNames module, but it will be by the time LanguageSupportPageNames gets out of development. 

Link to comment
Share on other sites

  • 2 months later...
Are there any news about the clone module working with multi language sites? I could really make good use of this in my current project...

It works on the dev branch. That's assuming you are using the built-in language support modules (LanguageSupport, LanguageSupportFields, LanguageSupportPageNames). Though I am still working out a bug where the multi-language page names don't get copied over to the clone, so don't bother setting the non-default language page names until after the clone is made. 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...