Dan 'Diplo' Booth
06/30/2022, 6:10 PMMenuRenderingNotification
to add a menu item (in this case to the DataTypes tree). This all works. But I only want to add my menu item when the item is actually a DataType and not a Folder (Container). The Notification
object has stuff like NodeId
and the tree alias, but how do I tell if the node being clicked on is a folder so I can avoid?Kevin Jump
07/01/2022, 9:10 AMif (int.TryParse(notification.NodeId, out int nodeId))
{
var container = _entityService.Get(nodeId);
if (container != null && containerTypes.Contains(container.NodeObjectType))
where containerTypes is an array of the 'container type values'
private Guid[] containerTypes = new Guid[]
{
UmbracoObjectTypes.DocumentTypeContainer.GetGuid(),
UmbracoObjectTypes.DataTypeContainer.GetGuid(),
UmbracoObjectTypes.MediaTypeContainer.GetGuid()
};
Dan 'Diplo' Booth
07/01/2022, 10:13 AMNotification
metadata.Kevin Jump
07/01/2022, 10:15 AMKevin Jump
07/01/2022, 10:26 AMvar container = _entityService.Get(int.Parse(id, CultureInfo.InvariantCulture), UmbracoObjectTypes.DocumentTypeContainer);
if (container != null)
{
// .... container stuff
}
else
{
var ct = _contentTypeService.Get(int.Parse(id, CultureInfo.InvariantCulture));
// content type stuff