Copied to clipboard

Flag this post as spam?

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


  • René Andersen 238 posts 684 karma points
    Jul 09, 2015 @ 08:16
    René Andersen
    0

    Macro Content Picker use NiceUrl

    Hi everybody

    I can't figure out how to get "NiceUrl" working with a Macro. My code looks like this:

    @inherits Umbraco.Web.Macros.PartialViewMacroPage    
    <p>
      <a class="btn btn-contrast" href="@Model.MacroParameters.NiceUrl["internalLink"]">Læs mere</a>
    </p>
    

    Is it possible to use "NiceUrl" with af Macro?

    Thanks in advance!

    // René

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Jul 09, 2015 @ 09:18
    Dennis Aaen
    100

    Hi René

    I am not sure that you can use NiceUrl with a parameter, but this should give the same that you are after using the parameter to choose the page that should be linked to.

    @inherits Umbraco.Web.Macros.PartialViewMacroPage
    
    @{ 
        var internalLink = Model.MacroParameters["internalLink"]; 
    }
    
    @if (internalLink != null)
    {
    
        var link = @Umbraco.Content(internalLink);
    
    
        <p>
            <a class="btn btn-contrast" href="@link.Url">Læs mere</a>
        </p>
    }
    

    Hope this helps,

    /Dennis

  • René Andersen 238 posts 684 karma points
    Jul 09, 2015 @ 09:22
    René Andersen
    0

    Hi Dennis

    That works beautifully.

    Thank you!

    // René

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies