Hi All
In the ContentService.Published event handler is there a way of getting the full path of the published entity in the content tree e.g. If I have a content tree of webpages/homefolder/home and I publish the "home" content file I would get "webpages/homefolder"
In the published event one of the arguments is the PublishEventArgs
you can use this to get the content item
e.PublishedEntities will contain the list of entities that have been published allowing you to then use the umbraco helper to get at any of the data you need.
you can get the site id by splitting the content item path variable
and so get the url using the NiceUrl method from the umbraco helper object.
e.g.
var umbracoHelper = new UmbracoHelper(UmbracoContext.Current);
var contentId = int.Parse(contentItem.Path.Split(',')[1]);
var contentUrl = umbracoHelper.NiceUrl(contentId);
I don't know if this is the best way but it should get the job done.
Read Content Tree in Publish EventHandler
Hi All In the ContentService.Published event handler is there a way of getting the full path of the published entity in the content tree e.g. If I have a content tree of webpages/homefolder/home and I publish the "home" content file I would get "webpages/homefolder"
Thanks!
In the published event one of the arguments is the PublishEventArgs
you can use this to get the content item
e.PublishedEntities will contain the list of entities that have been published allowing you to then use the umbraco helper to get at any of the data you need.
you can get the site id by splitting the content item path variable
and so get the url using the NiceUrl method from the umbraco helper object.
e.g.
I don't know if this is the best way but it should get the job done.
That works a treat! Thanks!
is working on a reply...