Copied to clipboard

Flag this post as spam?

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


  • Tom 161 posts 322 karma points
    Mar 19, 2015 @ 18:44
    Tom
    0

    How to pass a model to a macro

    I have a model class with one property that I need to pass to my macro.

    I am rendering my macro on my view as follows:

    @Umbraco.RenderMacro("listArticles")

     

    Can anyone tell me how I might be able to pass my model class to my macro?

     

    Thanks


    Tom

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Mar 19, 2015 @ 19:18
    Dennis Aaen
    0

    Hi Tom,

    Perhaps you can see this documentation https://our.umbraco.org/documentation/reference/templating/Mvc/views#RenderingMacros on how to render partial view macro with parameters.

    Hope this can help you,

    /Dennis

  • Tom 161 posts 322 karma points
    Mar 19, 2015 @ 19:54
    Tom
    0

    Thanks Dennis.  How do I pass a model class to my Macro?

     

    Tom

  • Tom 161 posts 322 karma points
    Mar 19, 2015 @ 20:04
    Tom
    0

    Dennis:

    This works...
    @Umbraco.RenderMacro("listArticles", new Mantle2.Models.ArticleTypeModel())

    Now on my  Mantle2.Models.ArticleTypeModel() class I have one property.
    How do I set its value to custom field (Category) found on my document type?

     

    Thanks 

Please Sign in or register to post replies

Write your reply to:

Draft