Copied to clipboard

Flag this post as spam?

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


  • Chris C 43 posts 184 karma points
    Nov 01, 2013 @ 19:22
    Chris C
    0

    Difference between MacroScript and MacroPartial?

    Ok, what is the difference between macroScripts (which sit in ~/macroScripts) and macroPartials (in ~/views/macropartials)?  I've noticed that some stuff doesn't work in one or the other. 

    It looks like macroScripts inherit from DynamicNodeContext, and you can use Model and CurrentModel.  And macroPartials have CurrentPage. 

    Why are there two things, and what is the recommended approach for doing development?

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Nov 01, 2013 @ 19:27
    Jeavon Leopold
    102

    Hi Chris,

    Assuming you are starting from a new with v6+, then consider MacroScripts legacy and don't use them.

    If you use MVC templates, then use Views & Partial Views mainly, MacroPartialViews only for when you need parameters, like a macro in the RTE. If you use MasterPages, then use MacroPartialViews for adding logic sections to your MasterPages through the Macro engine.

    MacroScripts were the first implementation of Razor in Umbraco introduced in v4.7 and fully replaced in v6 by the above options.

    Unfortunately MacroPartialViews are not very well documented yet, but essentially you can just treat them in the same way as a MVC View (even if using in Webforms).

    Does that make any sense?

    Jeavno

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Nov 01, 2013 @ 19:28
    Jeavon Leopold
    0

    MVC using Views and Partial Views is well documented here and also some great video tutorials on umbraco.tv

  • Chris C 43 posts 184 karma points
    Nov 01, 2013 @ 19:58
    Chris C
    0

    Thanks Jeavon.  That's exactly what I was looking for.  This is a new project on Umb V6+, so I won't use macroScripts. 

    It seems like CurrentPage is better anyway, because you can do CurrentPage.Property instead of Model.GetPropertyValue("prop"). 

     

     

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Nov 01, 2013 @ 20:04
    Jeavon Leopold
    0

    Ah yes, good question, CurrentPage is dynamic while Model.Content is typed which means you get intellisense in Visual Studio or WebMatrix , however Dynamic is more consise.

    It's really just preference.

  • Jeavon Leopold 3072 posts 13628 karma points MVP 10x admin c-trib
    Nov 01, 2013 @ 20:12
    Jeavon Leopold
    0

    There is a god blog post here which might be interesting also, it discusses that macros are rarely needed in v6 Mvc.

Please Sign in or register to post replies

Write your reply to:

Draft