开发者

Programmatically accessing sitecore layouts, templates and moving it to other site

开发者 https://www.devze.com 2023-02-11 19:21 出处:网络
We have a need to programmatically access the layouts/ templates of one sitecore site and move it to another site under different folders basically the intent is to restructure the existing site which

We have a need to programmatically access the layouts/ templates of one sitecore site and move it to another site under different folders basically the intent is to restructure the existing site which is already in pro开发者_JAVA百科duction.

Could anyone tell me how do we go about it?


Instead of writing a custom "one-time-use" tool for this, I would recommend you to get advantage of a standard "Transfer Items" application. You can find it in Sitecore Control Panel: go to Database > Transfer Items to Another Database.

So, what you basically need to do:

  • plug in the master database from the target new site to this older site, like "master_new" or something. This will require the web.config modification. The section on SDN about publishing targets should have a guideline how to do this
  • run the "Transfer Items" application, select the templates / layouts you needs on the first page, select this "master_new" database as a target database and the place in the content tree to transfer to on the second one
  • run the actual transfer

If your layouts / templates are groups into folders, this process will take the minimal time - much less comparing to creating your custom script...

UPDATE: Some sample code how to trigger this application programmatically:

UrlString url = new UrlString(UIUtil.GetUri("control:TransferToDatabase"));
Context.ClientPage.ClientResponse.ShowModalDialog(url.ToString());


I would look into using Sitecore Powershell Extensions (look at marketplace). It is a perfect fit for a usecase like this.

0

精彩评论

暂无评论...
验证码 换一张
取 消