Forums / Developer / Creating an object through the eZ Publish API

Creating an object through the eZ Publish API

Author Message

Nicolas Steinmetz

Thursday 03 April 2008 6:10:48 am

Hello,

To ease our migration from our internal version of our eZ Publish projects, I would like to be able to create/alter objects through a script and not in the back office in a manual way.

So I would like to know if the API allows :
- to create new object
- to update object attributes (mainly add news ones for my current needs)
- if it's feasible, where can I find some code samples and documentation to implement this.

Regards,
Nicolas

Maxime Thomas

Tuesday 08 April 2008 11:39:17 pm

Hi,

You may use a one shot cronjob. In order to do that, you can look at :
- runcronjobs.php and the cronjobs directory files, to understand how to design your cronjob
- this article in ezpedia :

http://ezpedia.org/wiki/en/ez/cronjob
http://ezpedia.org/wiki/en/ez/creating_new_content_objects_with_php

Hope it helps.

Chears.

Maxime Thomas
maxime.thomas@wascou.org | www.wascou.org | http://twitter.com/wascou

Company Blog : http://www.wascou.org/eng/Company/Blog
Technical Blog : http://share.ez.no/blogs/maxime-thomas

Ekkehard Dörre

Wednesday 09 April 2008 2:45:57 am

Hi Nicolas,

there are many examples in the http://ez.no/developer/contribs/import_export extensions. Or try to find an example here:
http://projects.ez.no/

Greetings, ekke

http://www.coolscreen.de - Over 40 years of certified eZ Publish know-how: http://www.cjw-network.com
CJW Newsletter: http://projects.ez.no/cjw_newsletter - http://cjw-network.com/en/ez-publ...w-newsletter-multi-channel-marketing

Nicolas Steinmetz

Wednesday 09 April 2008 3:45:53 am

Hi,

Thanks for the url.

Since my post, I could find the following one (for those who could also search for):

http://ez.no/developer/contribs/hacks/update_object_attributes

http://ez.no/developer/contribs/hacks/update_class_from_command_line

http://ezpedia.org/wiki/fr/ez/creating_new_content_objects_with_php

http://ezpedia.org/wiki/fr/ez/creating_new_content_object_versions_with_php

http://ezpedia.org/wiki/en/ez/import

but I had no time yet to dive into them.

Thanks for the link on the cronjob at is would save some time regarding the environnement initalisation.

For import/export contribs, I did not think about them this way. Thanks a lot too !

Regards,
Nicolas

eZ debug

Timing: Jan 20 2025 17:30:47
Script start
Timing: Jan 20 2025 17:30:47
Module start 'content'
Timing: Jan 20 2025 17:30:47
Module end 'content'
Timing: Jan 20 2025 17:30:47
Script end

Main resources:

Total runtime0.1777 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0065 591.4766180.8125
Module start 'content' 0.00650.0068 772.289197.9297
Module end 'content' 0.01330.1643 870.2188526.6250
Script end 0.1776  1,396.8438 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00372.0829200.0002
Check MTime0.00140.7829200.0001
Mysql Total
Database connection0.00110.644310.0011
Mysqli_queries0.122068.65291410.0009
Looping result0.00130.71691390.0000
Template Total0.163992.210.1639
Template load0.00090.513210.0009
Template processing0.163091.713410.1630
Override
Cache load0.00060.358510.0006
Sytem overhead
Fetch class attribute can translate value0.00080.455210.0008
XML
Image XML parsing0.00020.132310.0002
General
dbfile0.01267.1061200.0006
String conversion0.00000.002830.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs