cancel
Showing results for 
Search instead for 
Did you mean: 

Adding and Removing tags with the PHP library

dallinns
Champ on-the-rise
Champ on-the-rise
Is there a way to add and remove tags using just the php library? I have been using the rest-based functions from the Ifresco (http://forge.alfresco.com/projects/ifresco-phplib/) library, but now I have the problem of not being able to remove a tag. Also, if I could add a tag using just the php library and not an extended library that would be very helpful if anyone has an example of that.
3 REPLIES 3

ddanninger
Champ in-the-making
Champ in-the-making
Well if you dont wanna create a tag via the extended library -  ifresco PHP …. which implemented the REST Functionality you can make it another way…. everything in Alfresco is just a Node

So the therory to create a Tag is to add a new tag in "workspace://SpacesStore"
under /{http://www.alfresco.org/model/content/1.0}categoryRoot/{http://www.alfresco.org/model/content/1.0}ta..."

Which has the Node "workspace://SpacesStore/tag:tag-root" if you create a child node in there of the content type: "cm_category" it should work fine and it should be a tag then.

BUT actually with the basic library you will not be able to remove a Node , because the removeChild functionality is not implemented in the basic library thats why i wrote the ifresco PHP library.

Why dont u wanna use the library? Whats the problem at removing a tag?

dallinns
Champ on-the-rise
Champ on-the-rise
Whats the problem at removing a tag?
How do you do it?

ddanninger
Champ in-the-making
Champ in-the-making
Code is not tested there are two ways:

First one via normal library:


$Node->cm_tags = array("tag1","tag2");

(not sure if it works)

Second way via ifresco php lib:


$nodeId = "0000-00000-0000-000"; // or $Node->getId();
$Tags = array("tag1","tag2");
$RestTags = new RESTTags($repository,$spacesStore,$session);
$RestTags->AddNodeTags($nodeId,$Tags);

not tested but should work like that.