Skip to content

Instantly share code, notes, and snippets.

@dampee
Created April 14, 2015 15:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dampee/a77654eef93df7322753 to your computer and use it in GitHub Desktop.
Save dampee/a77654eef93df7322753 to your computer and use it in GitHub Desktop.
create umbraco macro with custom properties
// Using old namespace to create Macro, since Umbraco.Core.Models.Macro is still an internal class in Umbraco V7.1.8
var macro = new Macro.Macro { Alias = alias, Name = name, ScriptingFile = scriptingFile, UseInEditor = useInEditor, RenderContent = renderContent };
macro.Save();
var newMacro = Services.MacroService.GetByAlias(alias);
foreach (var macroProperty in macroProperties)
{
newMacro.Properties.Add(macroProperty);
}
Services.MacroService.Save(newMacro);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment