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.
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:
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":
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?
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.
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!
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:
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":
Hope this helps!
Best,
Niels...
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.
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.
is working on a reply...