Copied to clipboard

Flag this post as spam?

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


  • Aung Zin Phyo 17 posts 87 karma points
    Jan 09, 2020 @ 08:16
    Aung Zin Phyo
    0

    From UDI to Guid

            var udi = Udi.Parse(test);
            var page = Services.ContentService.GetById(Guid.Parse("ac0a00738fbb43d3b6ebd01928d61051"));
            string teee = page.GetValue("CarDetailsTitle").ToString();
    
  • Joep 90 posts 688 karma points
    Jan 11, 2020 @ 11:46
    Joep
    0

    Hi,

    Why would you need to convert the UDI to a Guid? You can just do a getbyid with a UDI.

    -Joep

  • Heather Floyd 531 posts 787 karma points MVP 2x c-trib
    Sep 16, 2020 @ 18:10
    Heather Floyd
    1

    Actually, in order to use the ContentService/MediaService, you can't just pass in a UDI, you need to convert it to a GuidUdi first. See: UDI and ContentService / GetValue<>

  • Enkosi 8 posts 80 karma points
    Dec 14, 2020 @ 12:50
    Enkosi
    0

    For anyone who lands here searching for how to get the UDI you can do the following:

    var udi = new GuidUdi(node.ContentType.ItemType.ToString(), node.Key);
    

    Otherwise, you can simply use the UmbracoHelper to get published content:

    var page = Umbraco.Web.Composing.Current.UmbracoHelper.Content(int Id);
    

    Please note there are method overrides for Content so you can get Content by:

    • Udi
    • string
    • int
    • object

    I hope that helps.

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" button below.

    Continue discussion

Please Sign in or register to post replies