本文整理汇总了PHP中eZContentObjectTreeNode::addChildTo方法的典型用法代码示例。如果您正苦于以下问题:PHP eZContentObjectTreeNode::addChildTo方法的具体用法?PHP eZContentObjectTreeNode::addChildTo怎么用?PHP eZContentObjectTreeNode::addChildTo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZContentObjectTreeNode
的用法示例。
在下文中一共展示了eZContentObjectTreeNode::addChildTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createObject
function createObject($contentClassID, $parentNodeID = 2)
{
$class = eZContentClass::fetch($contentClassID);
$parentNode = eZContentObjectTreeNode::fetch($parentNodeID);
$parentContentObject = $parentNode->attribute('object');
$sectionID = $parentContentObject->attribute('section_id');
$object = $class->instantiate(false, $sectionID);
// $parentContentObject = $parentNode->attribute( 'contentobject' );
$node = eZContentObjectTreeNode::addChildTo($object->attribute("id"), $parentNodeID, true);
// $object->setAttribute( "main_node_id", $node->attribute( 'node_id' ) );
$node->setAttribute('main_node_id', $node->attribute('node_id'));
$object->store();
$node->store();
return $object;
}
示例2: addLocation
/**
* Adds a new location (node) to the current object.
*
* Transaction unsafe. If you call several transaction unsafe methods you must enclose
* the calls within a db transaction; thus within db->begin and db->commit.
*
* @param int $parentNodeID The id of the node to use as parent.
* @param bool $asObject If true it will return the new child-node as an object, if not it returns the ID.
*
* @return eZContentObjectTreeNode|int
*/
function addLocation( $parentNodeID, $asObject = false )
{
$node = eZContentObjectTreeNode::addChildTo( $this->ID, $parentNodeID, true, $this->CurrentVersion );
$data = array( 'contentobject_id' => $this->ID,
'contentobject_version' => $this->attribute( 'current_version' ),
'parent_node' => $parentNodeID,
// parent_remote_id in node assignment holds remote id of the added location,
// not of the parent location or of the node assignment itself
'parent_remote_id' => $node->attribute( 'remote_id' ),
'is_main' => 0 );
$nodeAssignment = eZNodeAssignment::create( $data );
$nodeAssignment->setAttribute( 'op_code', eZNodeAssignment::OP_CODE_CREATE_NOP );
$nodeAssignment->store();
if ( $asObject )
{
return $node;
}
else
{
return $node->attribute( 'node_id' );
}
}