Login / Editing objects with AJAX

Author Message

Jérôme Vieilledent

Friday 29 August 2008 5:52:06 am

Hello

I would like to know if it was possible to login to eZPublish and edit content objects via AJAX and/or webservices... Indeed, I would like to allow my visitors to edit comments without having to display a dedicated page for the form (for example with a DIV fading in the page of the current viewed article).
Moreover, I plan to develop a webapp (or native Application like Wordpress has) for iPhone allowing contributors to manage content of their website on the iPhone. But I wonder how eZPublish can manage publishing this way...
Any idea ?

Thanks

Marco Zinn

Saturday 30 August 2008 3:06:26 am

Hi Jérôme,

as far as i know, ezPublish has a build-in SOAP server, so it should be possible to create an extension providing a webservice for editing object (or: creating comment objects, in your case).
But, if your client as a webbrowser, i guess, it's much easier to create an eZ publish template, which fits your need.
If i understand you right, you want to have a "comment box" inside the normal "view" template. I think, this should be possible by merging the "content/view/full" template with the "content/edit" template.
That is: insert the form of the edit template of the "comment" class into the "full view" template of the article/folder/product/whatever-template.

Just a wild guess, but that would be my approach.

Marco
http://www.hyperroad-design.com

André R.

Saturday 30 August 2008 3:27:40 pm

That is: insert the form of the edit template of the "comment" class into the "full view" template of the article/folder/product/whatever-template.

You'll need a custom view for that as well, the normal content/edit view creates a draft on every view so wouldn't work in this setting.

eZ Online Editor 5: http://projects.ez.no/ezoe || eZJSCore (Ajax): http://projects.ez.no/ezjscore || eZ Publish EE http://ez.no/eZPublish/eZ-Publish-Enterprise-Subscription
@: http://twitter.com/andrerom

Paul Borgermans

Monday 01 September 2008 2:12:17 am

Not really Ajax, but it avoids the creation of drafts when displaying a form:

http://projects.ez.no/powercontent

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Jérôme Vieilledent

Monday 01 September 2008 2:31:31 am

Thanks all for your replies :-)
Wouldn't it be easier if I called the content/edit view via AJAX ? I mean, for example a user clicks on "New comment" button which makes appear the comment box in javascript. The JS code then makes an AJAX call to display the right form... Of course I should first make an override rule for the pagelayout so that only the form would appear.
But what if the user closes the window without clicking on the Cancel button ? Is there a cronjob to clean the empty drafts ?

Paul Borgermans

Monday 01 September 2008 2:39:51 am

With the powercontent contrib, you won't have an empty draft. Ajaxify this mechanism would be a good option, but you can already have the quick comment form with some DHTML operating on a display attribute

Hth
Paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Jérôme Vieilledent

Monday 01 September 2008 3:06:34 am

If I understand well this extension, I just have to "prepare" my comment form in a hidden DIV, for example with the help of the <i>powercontent_attribute_create_gui</i> function.
My form doesn't submit to <i>/content/action</i> any more, but to <i>/powercontent/action</i>.
Then when the user clicks on the submit button, the comment will automatically be published ? If so, it's exactly what I need :-)

About the SOAP API, is there a place where I can find up-to-date documentation ?

Xavier Dutoit

Tuesday 02 September 2008 1:15:51 pm

Hi,

that's exactly the way it works indeed.

There is an option (hidden field) to automatically publish the content, don't forget to set it so you can come back to the page.

X+

P.S. You will have problems with spams, and some captcha extensions don't work with powercontent... ended up dirty tweeking, but might be a better option out there.

http://www.sydesy.com

Jérôme Vieilledent

Monday 08 September 2008 8:03:14 am

You will have problems with spams, and some captcha extensions don't work with powercontent... ended up dirty tweeking, but might be a better option out there.

In my case, only registered users would be able to post comments, so I think this extension exactly suits my needs :-)

Gaetano Giunta

Friday 18 June 2010 6:10:46 am

@Jerome: take a look at ezwebservicesapi

Principal Consultant International Business
Member of the Community Project Board

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 19 2025 06:25:56
Script start
Timing: Jan 19 2025 06:25:56
Module start 'layout'
Timing: Jan 19 2025 06:25:56
Module start 'content'
Timing: Jan 19 2025 06:25:57
Module end 'content'
Timing: Jan 19 2025 06:25:57
Script end

Main resources:

Total runtime1.0177 sec
Peak memory usage4,096.0000 KB
Database Queries86

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0054 589.1563152.6250
Module start 'layout' 0.00540.0030 741.781339.4453
Module start 'content' 0.00841.0078 781.2266809.0547
Module end 'content' 1.01620.0015 1,590.281324.1563
Script end 1.0177  1,614.4375 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00300.2927160.0002
Check MTime0.00130.1289160.0001
Mysql Total
Database connection0.00110.111010.0011
Mysqli_queries0.934491.8162860.0109
Looping result0.00100.1009840.0000
Template Total0.985396.820.4927
Template load0.00210.202820.0010
Template processing0.983396.615720.4916
Template load and register function0.00010.007910.0001
states
state_id_array0.00200.194110.0020
state_identifier_array0.00140.135120.0007
Override
Cache load0.00180.1817550.0000
Sytem overhead
Fetch class attribute can translate value0.00100.097360.0002
Fetch class attribute name0.00120.1208160.0001
XML
Image XML parsing0.00400.396460.0007
class_abstraction
Instantiating content class attribute0.00000.0035200.0000
General
dbfile0.00290.2830490.0001
String conversion0.00000.000840.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
10content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
10content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
13content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 42
 Number of unique templates used: 7

Time used to render debug report: 0.0002 secs