Move Master Page to new location

Posted by Community Admin on 03-Aug-2018 21:16

Move Master Page to new location

All Replies

Posted by Community Admin on 17-Feb-2011 00:00

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

Posted by Community Admin on 21-Feb-2011 00:00

Any thoughts anyone?

Posted by Community Admin on 23-Feb-2011 00:00

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

This thread is closed