Copied to clipboard

Flag this post as spam?

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


  • Onno Sloof 23 posts 43 karma points
    Mar 13, 2014 @ 11:51
    Onno Sloof
    0

    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

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Mar 13, 2014 @ 12:08
    Jeroen Breuer
    0

    Isn't replacing Model.Content with mainImage good enough?

    Jeroen

  • Onno Sloof 23 posts 43 karma points
    Mar 18, 2014 @ 13:13
    Onno Sloof
    0

    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 

  • Jeroen Breuer 4908 posts 12265 karma points MVP 4x admin c-trib
    Mar 18, 2014 @ 13:17
    Jeroen Breuer
    0

    Have a look at the this GetUrlPicker extension method I wrote. That should give back all the info you need.

    Jeroen

Please Sign in or register to post replies

Write your reply to:

Draft