Hello all, thanks in advance for any assistance. (As indicated by other posts, I've had an unexpectedly rough time working with the PHP API lately, so I will try to be more constructive by documenting specific questions.)I'm trying to complete a content import script, and one of the requirements is to add numerous categories to each new node. I have no troubles adding a single category by creating a NodeRef and setting it as the property:// $contentNode is my newly created content.
$contentNode->addAspect("{http://www.alfresco.org/model/content/1.0}generalclassifiable");
$results = $session->query($store, 'PATH:"/cm:generalclassifiable/cm:MyCategory"');
$category = $results[0];
$categoryNodeRef = "workspace://SpacesStore/".$category->getId();
$properties = $contentNode->getProperties();
$properties["{http://www.alfresco.org/model/content/1.0}categories"] = $categoryNodeRef;
$contentNode->setProperties($properties);
// save the session, etc.
But after trying numerous methods I cannot figure out how to do the same with two categories instead of just one. Using arrays will earn me "Array to string conversion" errors even though other content nodes with multiple categories (created via the admin view) actually display them in this manner. Here is a print_r example of a property array from an object created in the Alfresco Web Client with multiple categories set up: …
[{http://www.alfresco.org/model/content/1.0}creator] => dwilson
[{http://www.alfresco.org/model/content/1.0}created] => 2008-07-26T17:12:22.652-07:00
[{http://www.alfresco.org/model/content/1.0}categories] => Array
(
[0] => workspace://SpacesStore/c74a7372-5b71-11dd-941b-79398bf43fa6
[1] => workspace://SpacesStore/bc9d99c9-5b71-11dd-941b-79398bf43fa6
)
…Here Jean supports the idea that you can indeed treat the cm:categories property as an array in the Javascript API along with all other multi-valued properties.http://forums.alfresco.com/en/viewtopic.php?f=4&t=13879&p=45900&hilit=classification#p45900I have seen several similar posts for other APIs stating to add the properties along with the cm:generalclassifiable aspect, although this similarly does not work in PHP.http://forums.alfresco.com/en/viewtopic.php?f=36&t=15512&p=51344&hilit=categories#p51344var categories = new Array();
categories["cm:categories"] = catNodes;
upload.addAspect("cm:generalclassifiable", categories);(Of course the Javascript API has the CategoryNode object in place to support that code.)Thoughts?Thanks!Dave