Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gordon Saxby 1461 posts 1883 karma points
    Oct 19, 2015 @ 11:45
    Gordon Saxby
    0

    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!?

  • Gordon Saxby 1461 posts 1883 karma points
    Oct 20, 2015 @ 10:15
    Gordon Saxby
    0

    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);
        ....
    }
    
  • Dave Woestenborghs 3504 posts 12135 karma points MVP 9x admin c-trib
    Oct 20, 2015 @ 10:28
    Dave Woestenborghs
    0

    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

  • Gordon Saxby 1461 posts 1883 karma points
    Oct 20, 2015 @ 11:13
    Gordon Saxby
    0

    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?

Please Sign in or register to post replies

Write your reply to:

Draft