Forums / Developer / Wanted: documentation on creating contentObjects from scratch

Wanted: documentation on creating contentObjects from scratch

Author Message

Gabriel Ambuehl

Tuesday 06 May 2003 8:22:27 am

I'm trying to create content objects from scratch but when I look at http://ez.no/sdk/kernel/view/content_objects I have my trouble figuring out how to add attributes as the page only changes an existing object with existing attributes.

From what I can tell, I need to call
$new_content_object=(eZContentObject::create($name,$contentclassID,$userID,$sectionID));
to store a new object in my var.

Now I can call
$new_content_object->store();
to store it in the db.

But how can I store add attributes? Or fetch what attribute the content class I'm working with is supposed to provide, anyway?

$new_content_object->contentObjectAttributes()
returns an empyt array, so that can't be it.

Some more documentation (like the contentClass docs which are superb) for contentobject and contentobjectattribute would be very helpful. Especially SIMPLE, non-generic (genericity always adds A LOT of complexity) examples would be nice.

Visit http://triligon.org

Paul Borgermans

Tuesday 06 May 2003 9:19:17 am

Gabriel,

I use the following source to study this. Maybe it helps you too:

http://zev.ez.no/svn/nextgen/trunk/scrap/rotaryimport.php

I agree on your request for better docs, which is one of the priorities of the ez team now.

Paul

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

Gabriel Ambuehl

Friday 09 May 2003 8:40:36 am

Ok, so I have:
----------
$class =& eZContentClass::fetch( 28 );
// Create object by userid in sectionid
$contentObject =& $class->instantiate( $userID, $sectionID );

$nodeAssignment =& eZNodeAssignment::create( array(
'contentobject_id' => $contentObject->attribute( 'id' ),
'contentobject_version' => $contentObject->attribute( 'current_version' ),
'parent_node' => 1,
'is_main' => 1
)
);

$version =& $contentObject->version( 1 );
$contentObjectAttributes =& $version->contentObjectAttributes();

$contentObjectAttributes[0]->setContent( $structure->headers['from'] );
$contentObjectAttributes[0]->store();

$version->setAttribute( 'modified', eZDateTime::currentTimeStamp() );
$version->setAttribute( 'status', EZ_VERSION_STATUS_DRAFT );
$version->setAttribute( 'name', $name );

$version->store();
$contentObject->store();
$nodeAssignment->store();

$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObject->attribute( 'id' ), 'version' => 1 ) );

----------

But it doesn't quite work. I'd figure that the content object should be turning up in the root node but it won't (but it DOES get added to the db)

Visit http://triligon.org

eZ debug

Timing: Jan 30 2025 00:18:57
Script start
Timing: Jan 30 2025 00:18:57
Module start 'content'
Timing: Jan 30 2025 00:18:57
Module end 'content'
Timing: Jan 30 2025 00:18:57
Script end

Main resources:

Total runtime0.1510 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.0050 588.1875180.7969
Module start 'content' 0.00500.0070 768.984497.9766
Module end 'content' 0.01200.1389 866.9609527.4219
Script end 0.1510  1,394.3828 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00322.1160200.0002
Check MTime0.00130.8482200.0001
Mysql Total
Database connection0.00040.245710.0004
Mysqli_queries0.111974.12901410.0008
Looping result0.00090.62761390.0000
Template Total0.138691.810.1386
Template load0.00090.564810.0009
Template processing0.137791.216310.1377
Override
Cache load0.00060.392010.0006
Sytem overhead
Fetch class attribute can translate value0.00040.235710.0004
XML
Image XML parsing0.00020.124410.0002
General
dbfile0.00664.3501200.0003
String conversion0.00000.001930.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.0001 secs