When replacing Model.Content with mainImage, this is working with if (mainImage != null && mainImage.HasValue("externeLink"))
But the part ... returns a string and not the urlPicker object, so urlPicker.NewWindow and urlPicker.Title are not working. I also want to use the other properties of urlPicker.
How to get properties of UrlPicker used in media type
Hi,
I have a media type 'Image' and used the uComponents data type 'URL Picker' in it as property.
How do i change the code below so its working for var mainImage = Umbraco.TypedMedia(imageID);
(where mainImage is the Image object)
@using uComponents.DataTypes.UrlPicker.Dto;
@{
if (Model.Content.HasValue("urlPicker"))
{
var urlPicker = Model.Content.GetPropertyValue<UrlPickerState>("urlPicker");
if (urlPicker != null)
{
var urlPickerLinkTarget = (urlPicker.NewWindow) ? " target=\"_blank\"" : String.Empty;
<a href="@urlPicker.Url" @Html.Raw(urlPickerLinkTarget)>@urlPicker.Title</a>
}
}
}
Thanks
Onno
Isn't replacing Model.Content with mainImage good enough?
Jeroen
Hi Jeroen,
When replacing Model.Content with mainImage, this is working with if (mainImage != null && mainImage.HasValue("externeLink"))
But the part ... returns a string and not the urlPicker object, so urlPicker.NewWindow and urlPicker.Title are not working.
I also want to use the other properties of urlPicker.
Onno
Have a look at the this GetUrlPicker extension method I wrote. That should give back all the info you need.
Jeroen
is working on a reply...