Forums / Setup & design / ezpublish edit button for frontend editing of content items
nicholas king
Monday 07 March 2011 8:33:39 am
Hello all, i have a question about frontend editing of content objects within a page.
currently i have this template
{def $current_user=fetch( 'user', 'current_user' )}{if $current_user.contentobject.can_edit|eq(true)}<a href="/content/edit/{$active_node.contentobject_id}/">[edit]</a>
which allows for a edit button to be displayed next to content objects on a page. This gets around some of the shortcomings of the ezwebtoolbar which only allows editing of the current node.
My question however is this, when someone edits the items using this button they are redirected back to / instead of the node from where they clicked the button. I have tried mimicking the the way the webtoolbar does editing through a web form, but still it redirects back to the / page. Any ideas on how to get the editor to redirect back to the page the button was clicked from.
Thanks
Nicholas
Frédéric DAVID
Tuesday 08 March 2011 3:21:47 am
Hi,
to override publish redirection, you can add a hidden button in your edit form.
<input type="hidden" name="RedirectURIAfterPublish" value="your_custom_url" />
You have the same for discard. The button name will be RedirectIfDiscarded
Blog : http://www.frefred.fr/blog/ez-publish feZ Meta Data : http://projects.ez.no/fezmetadata
Tuesday 08 March 2011 6:26:27 am
Hello Frederic,
I have tried this and it still redirects back to /
currently i have this code
<form method="post" action="/content/action" class="left"> <input type="hidden" name="ContentLanguageCode" value="eng-GB" /> <input type="image" src="/extension/ezwt/design/standard/images/websitetoolbar/ezwt-icon-edit.gif" name="EditButton" title="Edit:{$active_node.data_map.name.content}" /> <input type="hidden" name="HasMainAssignment" value="1" /> <input type="hidden" name="ContentObjectID" value="{$active_node.contentobject_id}" /> <input type="hidden" name="NodeID" value="{$active_node.node_id}" /> <input type="hidden" name="ContentNodeID" value="{$active_node.node_id}" /> <input type="hidden" name="ContentObjectLanguageCode" value="eng-GB" /> <input type="hidden" name="RedirectURIAfterPublish" value="{$active_node.path_identification_string}" /> <input type="hidden" name="RedirectIfDiscarded" value="{$active_node.path_identification_string}" /> </form>
Tuesday 08 March 2011 8:41:14 am
I think your form is wrong.
When you edit a objet ( content/edit ), the form action is content/edit, and not content/action like your example.
You have to do the change in your template template/content/edit.tpl ( override the template is the best way )
Wednesday 09 March 2011 2:28:36 am
Hello Frederic i have tried as you have suggested and still no success :-(, the page still redirects back to the home page. I don't really want to create a override template as the button i have created is already in wide use i would rather ammend my current template with the solution.