Share » Forums » Developer » Creating an article on the fly

Creating an article on the fly

Creating an article on the fly

Friday 13 April 2007 12:19:46 am - 2 replies

Author Message

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.

You must be logged in to post messages in this topic!

36 542 Users on board!

Forums menu