Copied to clipboard

Flag this post as spam?

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


  • Claushingebjerg 939 posts 2574 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 2155 posts 14406 karma points MVP 9x c-trib
    May 16, 2019 @ 14:09
    Marc Goodson
    101

    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 939 posts 2574 karma points
    May 20, 2019 @ 06:51
    Claushingebjerg
    0

    Yup, that works perfectly, thank you H5YR

Please Sign in or register to post replies

Write your reply to:

Draft