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?
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).
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.
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?
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
MVC using Views and Partial Views is well documented here and also some great video tutorials on umbraco.tv
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").
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.
There is a god blog post here which might be interesting also, it discusses that macros are rarely needed in v6 Mvc.
is working on a reply...