SetTagsValue does not allow you to set a Tag Group
Hi,
I am rewriting an Umbraco 7 site in Umbraco 8. The method for setting tags in v7 (IContentBase.SetTags) has an optional parameter for setting the tag group.
The equivalent method for v8 (SetTagsValue) does not have this facility. Looking at the source for v8 it appears to be missing - there is an internal static method which is passed the TagConfiguration though the Group name is ignored in the implementation.
I need to set the Group for tags on images to the id of the Folder in which they reside as part of the image import process. This is acheived in v7 using:
On inspection it seems that a Tag property added as an extension of the Image media type (and probably other types) must have the Tag group name set and it can't be overridden on an image by image basis.
I have resorted to building the list of tags for images in a folder the hard way (note: I'm using a strongly typed Model with ModelsBuilder):
SortedDictionary<string, int> tags = new SortedDictionary<string, int>();
foreach (GalleryImageMedia img in folder.Children)
{
foreach (string tag in img.Tags)
{
if (tags.ContainsKey(tag))
{
tags[tag] = tags[tag] + 1;
}
else
{
tags.Add(tag, 1);
}
}
};
SetTagsValue does not allow you to set a Tag Group
Hi,
I am rewriting an Umbraco 7 site in Umbraco 8. The method for setting tags in v7 (IContentBase.SetTags) has an optional parameter for setting the tag group.
The equivalent method for v8 (SetTagsValue) does not have this facility. Looking at the source for v8 it appears to be missing - there is an internal static method which is passed the TagConfiguration though the Group name is ignored in the implementation.
I need to set the Group for tags on images to the id of the Folder in which they reside as part of the image import process. This is acheived in v7 using:
img.SetTags("myTagField", myArrayOfTags, true, parentFolderId.ToString());
Is there any way to get round this?
Any help will be gratefully receieved.
Scotty
Update
On inspection it seems that a Tag property added as an extension of the Image media type (and probably other types) must have the Tag group name set and it can't be overridden on an image by image basis.
I have resorted to building the list of tags for images in a folder the hard way (note: I'm using a strongly typed Model with ModelsBuilder):
is working on a reply...