Monday 03 March 2008 8:23:05 am
Hi, thx David I have a new problem with this code when setting attributes values. The name of the created folder was supposed to be "test", but, instead, it was "Folder", how can I fix it? <?
include_once("kernel/common/template.php");
include_once("kernel/classes/datatypes/ezuser/ezuser.php");
include_once('lib/ezutils/classes/ezoperationhandler.php');
include_once("kernel/classes/ezcontentclass.php");
include_once("kernel/classes/ezcontentobjecttreenode.php"); include_once("kernel/classes/eznodeassignment.php");
$user_id=12; $parentNodeID=2; $class = eZContentClass::fetchByIdentifier('folder');
$parentContentObjectTreeNode = eZContentObjectTreeNode::fetch($parentNodeID);
$parentContentObject = $parentContentObjectTreeNode->attribute("object");
$sectionID = $parentContentObject->attribute('section_id'); $contentObject = & $class->instantiate($user_id, $sectionID); $nodeAssignment =& eZNodeAssignment::create(array('contentobject_id' => $contentObject->attribute('id'),'contentobject_version' => $contentObject->attribute('current_version'), 'parent_node' => $parentContentObjectTreeNode->attribute('node_id'),'is_main'=>1));
$nodeAssignment->store();
$contentObject->setAttribute('name','test'); $contentObject->store();
$attribs =& $contentObject->contentObjectAttributes();
$loopLength = count($attribs); for($i=0;$i<$loopLength;$i++){
switch($attribs[$i]->attribute("contentclass_attribute_identifier")){
case 'short_name':
echo 'nome <br /><br />'.$title;
$attribs[$i]->setAttribute('short_name','test');
$attribs[$i]->store();
break; } }
$contentObject->setAttribute('status',EZ_VERSION_STATUS_DRAFT); $contentObject->store(); $operationResult = eZOperationHandler::execute('content', 'publish',array('object_id'=>$contentObject->attribute('id'),'version'=>1));
}
} } ?>
eZ Publish Certified Developer: http://auth.ez.no/certification/verify/376924
Twitter: http://twitter.com/tcv_br
|