Copied to clipboard

Flag this post as spam?

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


  • Alex Gill 26 posts 61 karma points
    Dec 06, 2013 @ 13:39
    Alex Gill
    0

    Set Master Template on a new template created through API

    When creating a template using the API (new Template(path, name, alias) how do I set the Master Template so that it appears in the right place in the Umbraco back office? The content of the template sets the Layout property:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage
    @{
        Layout = "MasterView.cshtml";
    }
    

    but this doesn't get carried over to the "Master Template" property and I don't know how to set that in code?

  • Alex Gill 26 posts 61 karma points
    Dec 06, 2013 @ 13:57
    Alex Gill
    0

    A workaround is to use the old umbraco.cms.businesslogic.template namespace (yuck)

    var oldTemplate = Template.GetTemplate(myTemplate.Id);
    oldTemplate.MasterTemplate = masterTemplate.Id;
    oldTemplate.Save();
    
Please Sign in or register to post replies

Write your reply to:

Draft