More in this section

Forums / General Discussions / Move Master Page to new location

Move Master Page to new location

3 posts, 0 answered
  1. Richard
    Richard avatar
    164 posts
    Registered:
    21 Nov 2009
    17 Feb 2011
    Link to this post
    Hi

    I need to move where my Master page is located to another folder. How can I do this without breaking the link, as if the link breaks at any point I believe I will lose all my content of templates and pages. I have one master template based on a master page and then templates based on the master template and then pages based on the templates. If I copy the master page to the new location and then reassign the master template to be based on the master page in it's new location, will this work? Or what about if I edited the file path that must be stored in the SQL database directly without Sitefinity being open, would this work?

    Thanks

    Cheers
    Richard
  2. Richard
    Richard avatar
    164 posts
    Registered:
    21 Nov 2009
    21 Feb 2011
    Link to this post
    Any thoughts anyone?
  3. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    23 Feb 2011
    Link to this post
    Hello Richard Cross,

    Create a new master page which has the same markup/code of the original one. Then use the bellow code to change the master page from the API:

    var pageManager = PageManager.GetManager();
    var template = pageManager.GetTemplates().Where(t => t.MasterPage == "~/App_Data/Sitefinity/WebsiteTemplates/StarterKitBaseTemplate/App_Master/BaseTemplate.master");
    foreach(var temp in template)
        temp.MasterPage = "~/App_Data/Sitefinity/WebsiteTemplates/StarterKitBaseTemplate/App_Master/BaseTemplate2.master";
    pageManager.SaveChanges();

    Greetings,
    Radoslav Georgiev
    the Telerik team
3 posts, 0 answered