Copied to clipboard

Flag this post as spam?

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


  • Stefan Karlsson 14 posts 64 karma points
    Feb 05, 2014 @ 09:43
    Stefan Karlsson
    0

    v. 6.0 UrlPicker value for NewWindow

    Hi, i am trying to use the urlpicker provided inside ucomponents but i cant catch the value of NewWindow inside my razor macro.

    What am i doing wrong?

    @inherits umbraco.MacroEngines.DynamicNodeContext  
    
    @{
        string target = Model.marketBarTarget.NewWindow ? "_blank" : "_self";
    
        @target
    
        if (Model.HasValue("marketBarImage"))
        {
    
            if (Model.HasValue("marketBarUrl"))
            {
                @:<a href="@Model.marketBarUrl.Url" alt="@Model.marketBarAltText" target=@target>
            }
            else
            {
                @:<a href="">
            }
    
            @: <img src="@Model.MediaById(Model.marketBarImage).umbracoFile"></a>
    }
    }
    

    I also want to know if there is any way with umbraco that allows me to create a property "wrapper" that contains more than 1 datatype, and then allow me to use that property as multiple.

    With multiple i mean my user should be enable to determine how many times he want to add that custom property wrapper.

  • Anthony Southworth 48 posts 175 karma points
    Feb 10, 2014 @ 19:50
    Anthony Southworth
    0

    I think it should be newwindow (lowercase). For the multiple part, I'd look at what ucomponents has or maybe build your own.

    Cheers Tony

  • Jeavon Leopold 3074 posts 13632 karma points MVP 11x admin c-trib
    Feb 10, 2014 @ 20:23
    Jeavon Leopold
    0

    Hi Stefan,

    Give this a try:

    @using uComponents.DataTypes.UrlPicker.Dto
    @using umbraco.MacroEngines
    @inherits DynamicNodeContext
    @{
        if (Model.HasValue("marketBarImage"))
        {
            var urlPicker = UrlPickerState.Deserialize(Model.marketBarImage);
            if (urlPicker != null && !String.IsNullOrEmpty(urlPicker.Url))
            {
                var linkTarget = (urlPicker.NewWindow) ? " target=\"_blank\"" : string.Empty;
                <a href="@urlPicker.Url" @Html.Raw(linkTarget)>@urlPicker.Title</a>
            }
        }
    }
    

    Jeavon

Please Sign in or register to post replies

Write your reply to:

Draft