Forums / Developer / Single click copy then edit?

Single click copy then edit?

Author Message

Brendan Pike

Monday 26 March 2007 11:30:25 pm

I want to enable users to with a single click, create a copy of an object and then place them immediately in edit mode of the newly copied object. I want to do this within the templates if possible.

I succeeded in the copy part by placing the copy button within its own form and holding the required values for example:

<form action="/content/copy" method="post">
<input type="hidden" name="ObjectID" value="30707" />
<input type="hidden" name="BrowseActionName" value="CopyNode" />
<input class="button" name="SelectButton" value="Select" type="submit">
<input type="hidden" name="SelectedNodeIDArray[]" value="1543">
</form>

But to place the user in edit mode is more difficult, I don't think I can use the usual RedirectURI function because I don't yet know the NodeID of the object that will be created. I briefly tested the new BackToEdit checkbox that can be enabled in the admin side but I think it only works once already in edit mode.

So can this be done, or if it can't is there a way I can alter the name of the new object so it can be easily identified as the copy and not the original?

Thanks

www.dbinformatics.com.au

We are always interested in hearing from experienced eZ PHP programmers and eZ template designers interested in contract work.

Ɓukasz Serwatka

Tuesday 27 March 2007 12:09:12 am

This is not supported by default. Copy is finalized with publish operation, so It should be possible to run after-publish workflow event that redirects user to edit mode after copy, then you can have new node/object ID, etc. You can give a try.

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

Brendan Pike

Thursday 29 March 2007 9:40:41 pm

Thanks for your reply Luke

If I was to use a work to throw a user immediately into edit mode after making a copy how would that workflow distinguish between a normal publish object and a fresh copy?

Also any idea's about how to rename or make the copied object easy to identify?

Cheers

www.dbinformatics.com.au

We are always interested in hearing from experienced eZ PHP programmers and eZ template designers interested in contract work.

Kristof Coomans

Thursday 29 March 2007 11:37:14 pm

Hi Brendan

You can also redirect to edit mode with a small hack in kernel/content/copy.php:

Replace

return $Module->redirectToView( 'view', array( 'full', $newParentNodeID ) );

with

return $Module->redirectToView( 'edit', array( $newObject->attribute( 'id' ) ) );

independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org

James Ward

Friday 25 April 2008 9:28:59 am

Kristof,
You are the man. I can't tell you how much time this saved me. Hack works great in ez3.10.

working at www.wardnet.com
blogging at www.jamesward.ca