Move Master Page to new location
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
Any thoughts anyone?
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();