At what point is the URL for a node obtainable in the "save and publish" process?
I appreciate that it will be in the cache for an existing node, but I assume that will be the previous version and may have changed on this save & publish.
Do I need to wait until the "Published" event fires, or is the URL already set when entering the "Publishing" event?
I need to do some custom validation based on a node's Url. If I can't get the Url until the "Published" event, then I would have to alter values and save/publish or undo the publish!?
I have tried putting code in PublishingStrategy.Publishing as well as PublishingStrategy.Published and neither of those seem to allow me to get the node Url (of a new node).
I tried this, but it just returns #
foreach (var entity in e.PublishedEntities)
{
....
var helper = new UmbracoHelper(UmbracoContext.Current);
var entityUrl = helper.Url(entity.Id);
....
}
Maybe you can hook in to the PageCacheRefresher.CacheUpdated event.
This will run when the cache is updated. Keep in mind that if you are running a load balanced environment this will execute on all servers. Where ContentService.Published event only runs on the server where it has been triggered.
Umm, possibly. Ideally, I want to stop new or existing nodes being published if their Url (what their Url will be when published) matches an exclusion list.
Maybe I need to recreate what the "Url" function does?
Get node URL during Save & Publish
At what point is the URL for a node obtainable in the "save and publish" process?
I appreciate that it will be in the cache for an existing node, but I assume that will be the previous version and may have changed on this save & publish.
Do I need to wait until the "Published" event fires, or is the URL already set when entering the "Publishing" event?
I need to do some custom validation based on a node's Url. If I can't get the Url until the "Published" event, then I would have to alter values and save/publish or undo the publish!?
I have tried putting code in PublishingStrategy.Publishing as well as PublishingStrategy.Published and neither of those seem to allow me to get the node Url (of a new node).
I tried this, but it just returns #
Maybe you can hook in to the PageCacheRefresher.CacheUpdated event.
This will run when the cache is updated. Keep in mind that if you are running a load balanced environment this will execute on all servers. Where ContentService.Published event only runs on the server where it has been triggered.
Dave
Umm, possibly. Ideally, I want to stop new or existing nodes being published if their Url (what their Url will be when published) matches an exclusion list.
Maybe I need to recreate what the "Url" function does?
is working on a reply...