Creating an article on the fly

Author Message

Fabien Mas

Friday 13 April 2007 12:19:46 am

Hi everybody,

I have some data that I want to insert in a new article, manually with the code
How do I process ?

thx, Fabien

Jacques Feix

Friday 13 April 2007 6:03:09 am

Here is a sample of my own ;)

	$elementClass=eZContentClass::fetchByIdentifier("article");
	$classAttributes =& $elementClass->fetchAttributes();

	$element =& $elementClass->instantiate($userID,$sectionID,false,$languageCode);
        $elementID = $element->attribute('id');

	$nodeAssignement =& eZNodeAssignment::create
	        (array('contentobject_id' => $elementID,
	               'contentobject_version' => $element->attribute('current_version'),
	               'parent_node' => $parentID,
	               'is_main' => 1));
	$nodeAssignement->store();
	
	$elementVersion =& $element->version($element->attribute('current_version'));
	$elementVersion->setAttribute('status', EZ_VERSION_STATUS_DRAFT);
	$elementVersion->store();

	$datamap = $elementVersion->dataMap();

	    // Titre
	    $attribute = $datamap["title"];
	    $attribute->setAttribute('data_text', $this->Nom);
	    $attribute->store();

	    // short_title
	    $attribute = $datamap["short_title"];
	    $attribute->setAttribute('data_text', $this->Nom);
	    $attribute->store();
//.... other attributes ..

	    $operationResult =& eZOperationHandler::execute
	          ('content', 'publish',
	           array('object_id' => $elementID,
	             'version' => $element->attribute('current_version')));

nehal shah

Thursday 20 January 2011 12:09:01 am

Hi guyz

I have the same problem, i m trying to insert article programatically . i tried above code in my eZ-Publish(4.3) but it doesn't work. Please help me out.

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