Tuesday 16 December 2003 1:55:13 am
Hello together,
i made some progress. I did the following:
First I followed Jerrys tutorial: http://www.ez.no/developer/ez_publish_3/documentation/development/extensions/module/module_tutorial_part_1
Then I pasted inside the mymodulefunctioncollection.php the code from claus (thanks to both of you:)
this is the mymodulefunctioncollection.php:
---------------------
include_once( 'extension/mymodule/modules/mymodule/mymodule.php' ); include_once( 'kernel/classes/ezcontentobjecttreenode.php' );
class MyModuleFunctionCollection {
function MyModuleFunctionCollection()
{ }
function &fetchList( $offset, $limit )
{
$parameters = array( 'offset' => $offset,
'limit' => $limit ); $lista =& Mymodule::fetchListFromDB( $parameters ); while (list ($key, $val) = each ($lista)) {
// $contentClassId = 2; // For article (title (required), intro (required), body
$contentClassId = 10; // For info page (name (required), body
// $contentClassId = 14; // For ImportArticle (name (required), body
//fetch this class
$class =& eZContentClass::fetch( $contentClassId );
$userID = 1; //The userId creating it. Root = 1
// Instantiate the object with user $userID and put it in section 1. $contentObject =& $class->instantiate( $userID, 1 );
$name = "Blah blablablablabla"; //What should this be? //Answer: Object name $contentObject->setAttribute( 'name', $name ); $parentNodeID = 2; // choose where to put the object
$nodeAssignment =& eZNodeAssignment::create( array(
'contentobject_id' => $contentObject->attribute( 'id' ),
'contentobject_version' => $contentObject->attribute( 'current_version' ),
'parent_node' => $parentNodeID,
'sort_field' => 2,
'sort_order' => 0,
'is_main' => 1
)
); $nodeAssignment->store(); $version =& $contentObject->version( 1 );
$version->setAttribute( 'status', EZ_VERSION_STATUS_DRAFT ); $version->store();
$contentObjectID = $contentObject->attribute( 'id' ); $contentObjectAttributes =& $version->contentObjectAttributes(); $attributeValue = $key . ' and ' . $val;
$contentObjectAttributes[0]->setAttribute( 'data_text', $attributeValue); $contentObjectAttributes[0]->store();
$contentObjectAttributes[1]->setAttribute( 'data_text', $attributeValue); $contentObjectAttributes[1]->store(); $contentObject->store();
// Publish it
include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $contentObjectID,
'version' => 1 ) ); }
return array( 'result' => &$lista ); }
} ----------------------------- Okey, this isn't a nice hack, but anyway. Now I can import the data from the tutorial db table via /index.php/news_admin/mymodule/list (as you can see, i'm working in the news sample installation)
The following problems are remaining:
1) I had to modify the xml textfield to textfield of the class 'info page', because the scriptlet above failes at xml fields.
2) a new created class runs into an error, so i had to use the info class. 3) there are errors remaining in the debug: Can't open file: 'ezsearch_object_word_link.MYI' I'm going now to extend the db table from the tutorial.
best regards, andreas
|