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

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 18 2025 10:21:34
Script start
Timing: Jan 18 2025 10:21:34
Module start 'layout'
Timing: Jan 18 2025 10:21:34
Module start 'content'
Timing: Jan 18 2025 10:21:35
Module end 'content'
Timing: Jan 18 2025 10:21:35
Script end

Main resources:

Total runtime0.8587 sec
Peak memory usage4,096.0000 KB
Database Queries57

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0075 588.1797152.6563
Module start 'layout' 0.00750.0028 740.835939.5078
Module start 'content' 0.01030.8465 780.3438551.1641
Module end 'content' 0.85680.0019 1,331.507812.0938
Script end 0.8586  1,343.6016 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00380.4452160.0002
Check MTime0.00150.1805160.0001
Mysql Total
Database connection0.00140.159610.0014
Mysqli_queries0.794892.5636570.0139
Looping result0.00130.1527550.0000
Template Total0.821495.720.4107
Template load0.00230.271820.0012
Template processing0.819195.384420.4095
Template load and register function0.00030.031410.0003
states
state_id_array0.00120.136310.0012
state_identifier_array0.00150.171820.0007
Override
Cache load0.00190.2238470.0000
Sytem overhead
Fetch class attribute can translate value0.00060.072320.0003
Fetch class attribute name0.00130.155840.0003
XML
Image XML parsing0.00090.108320.0005
class_abstraction
Instantiating content class attribute0.00000.001240.0000
General
dbfile0.00090.1094170.0001
String conversion0.00000.001140.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
3content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
11content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
9content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
1content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 26
 Number of unique templates used: 6

Time used to render debug report: 0.0002 secs