How to find and get the value of umbraco contentpicker? Actually the umbraco return some digit value for that contentpicker, so iwant to convert that to display the exact value on screen
How to do this?
Actually i have tried to get umbraco content page property values for generating xml file. in this some content page has umbraco contentpicker (provide some url) and i want to read this property value.
already i have handle list of item by using umbraco.library method GetPreValuAsString, so same like this i want to get contentpicker value also
In the example it's shown how to get the name but I suppose you should be able to write .Url to get the url instead for instance.
Otherwise you should be able to fetch the id/udi and the pass it to @Umbraco.TypedContent like Louis tried to illustrate in the code examples he provided above.
I hope this helps!
If not then please try to provide a code example so we can get your context :)
Is that possible to get the content picker value by using the umbraco library, because when i try to read the node it return some digits (like : 1430) so that i want to try to convert that to appropriate value (liek url)
Without knowing exactly what you are trying to achieve, I can only guess that you are trying to get the url from the content picker control on a page to then place that url in an xml document, right?
There are a few ways to get url from a content picker control:
int typedContentPickerId = Model.Content.GetPropertyValue<int>("contentPickerAlias");
if (typedContentPickerId > 0)
{
var url1 = Umbraco.NiceUrl(typedContentPickerId);
var url2 = Umbraco.TypedContent(typedContentPickerId).Url;
var url3 = Umbraco.TypedContent(typedContentPickerId).UrlAbsolute();
}
How to get the value of content picker property
How to find and get the value of umbraco contentpicker? Actually the umbraco return some digit value for that contentpicker, so iwant to convert that to display the exact value on screen How to do this?
Hi Thomas,
The number that you are seeing returned is the ID of the content/image from the picker.
To use that ID on your page, you need to write some code similar to
For content:
For Images:
See
for more details on this.
Is this what you are looking for?
Louis
Hi Louis,
Thanks for the update.
Is that possible to the value of contentpicker by using umbraco.library ?
Hi Thomas,
To fully understand your question, can you give us some context on what you are trying to achieve? This will help us formulate a more accurate answer.
Louis
Actually i have tried to get umbraco content page property values for generating xml file. in this some content page has umbraco contentpicker (provide some url) and i want to read this property value.
already i have handle list of item by using umbraco.library method GetPreValuAsString, so same like this i want to get contentpicker value also
Ho to do this?
Hi Thomas
Have you tried using the snippet provided in the documentation for the content picker here https://our.umbraco.com/documentation/Getting-Started/Backoffice/Property-Editors/Built-in-Property-Editors/Content-Picker2#typed-example ?
In the example it's shown how to get the name but I suppose you should be able to write .Url to get the url instead for instance.
Otherwise you should be able to fetch the id/udi and the pass it to @Umbraco.TypedContent like Louis tried to illustrate in the code examples he provided above.
I hope this helps!
If not then please try to provide a code example so we can get your context :)
/Jan
Hi Jan thanks for the update.
Is that possible to get the content picker value by using the umbraco library, because when i try to read the node it return some digits (like : 1430) so that i want to try to convert that to appropriate value (liek url)
So is that possible ?
Like Jan says in his example link...
Hi Louis
I have tried with umbracohelper like below
var url = umbracoHelper.NiceUrl(1305);
Could you please let me know is that correct way? or is there any problem with this
Hi Thomas,
Without knowing exactly what you are trying to achieve, I can only guess that you are trying to get the url from the content picker control on a page to then place that url in an xml document, right?
There are a few ways to get url from a content picker control:
Hope this helps
Louis
is working on a reply...