Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 886 posts 2415 karma points
    May 16, 2019 @ 07:48
    Claushingebjerg
    0

    Getting macro parameters in v8

    I have a rich text editor in a nested content doc type, where i have a macro with a parameter...

    How do i render that parameter in my Partial view macro file?

    var myParam = Model.GetParameterValue<string>("citation");  
    

    returns:

    'PartialViewMacroModel' does not contain a definition for 'GetParameterValue'

     var myParam = Model.MacroParameters["citation"];
    

    returns:

    System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary.

  • Marc Goodson 1451 posts 9716 karma points MVP 5x c-trib
    May 16, 2019 @ 14:09
    Marc Goodson
    100

    Hi Claushingebjerg

    First thought, is the GetParameterValue is still there in V8

    https://github.com/umbraco/Umbraco-CMS/blob/853087a75044b814df458457dc9a1f778cc89749/src/Umbraco.Web/Models/PartialViewMacroModelExtensions.cs

    but it's an extension method if you add:

    @using Umbraco.Web.Models
    

    to the top of your PartialViewMacro does that make it work?

    regards

    Marc

  • Claushingebjerg 886 posts 2415 karma points
    May 20, 2019 @ 06:51
    Claushingebjerg
    0

    Yup, that works perfectly, thank you H5YR

  • 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