Copied to clipboard

Flag this post as spam?

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


  • Joe Woodhead 2 posts 82 karma points
    Jul 01, 2018 @ 10:42
    Joe Woodhead
    0

    Umbraco Cloud - Different type content Id's between deployments

    Hi all,

    So I've just been getting up and running with Umbraco cloud and my sites TypedContent Id's change depending on where it's deployed, meaning to get my site working I have to change it depending on where it's deployed (local environment at home, local environment at work and live deployment).

    I'm not really sure how these values are not kept static between deployments. If they're not, is there another way I can try find the content Id for whatever version I'm on? Or alternatively can anyone explain how I can keep all local and live deployment keys in sync?

    I'm new to CMS's but not new to development and this sort of detachment is confusing to me... I've been looking for an answer to this but haven't seemed to find one in the documentation or on the forum but I may have missed it.

    Thanks in advance!

  • Niels Hartvig 1951 posts 2391 karma points c-trib
    Jul 01, 2018 @ 11:55
    Niels Hartvig
    101

    Hi Joe!

    Ids in Umbraco should not be used to identify items in code as they can change when you move data from one instance to another.

    Ideally you should try to reference items in a way that's not explicit in code as this leaves editors relying on a developer if something later changes. Instead you can add a content picker on the type of content where you want a reference and refer to that in your code. In the scenario below I've added some promoted content as a Content Picker on my home node and in my code I can get the always up to date ID of the promoted content by asking for the "promoContent" property: enter image description here

    Alternatively you could normally use a generic xpath reference in a way where the referenced item can be selected

    If you need to reference an item via an id you should use the GUID (the long id underneath the id on the info tab which never changes). In this case the id of the item is 1047, but the guid is "7216ebdf-81e4-4a0d-994f-7de180679b79": enter image description here

    Hope this helps!

    Best,

    Niels...

  • Joe Woodhead 2 posts 82 karma points
    Jul 01, 2018 @ 21:07
    Joe Woodhead
    0

    Ah ok fair enough, thanks Niels. I thought there'd have to be some standard I wasn't following :)

    I'm coming purely from a backend dev background so all this CMS stuff adds a pretty confusing layer of abstraction!

    In the reply you mention if I need to reference something by Id then I should get the use the GUID? What about in situations where I've already retrieved the dynamically generated ID? Is there any disadvantage in that scenario?

    Thanks again.

  • Niels Hartvig 1951 posts 2391 karma points c-trib
    Jul 02, 2018 @ 05:19
    Niels Hartvig
    0

    Then it's completely fine to use the id. We're increasingly switching over to GUID based ids (or "UDIs" as they're called in Umbraco). So don't be surprised if the value returned dynamically is looking like a combo of a uri and a GUID.

Please Sign in or register to post replies

Write your reply to:

Draft