+1-888-365-2779
Try Now
More in this section

Forums / Designing with Sitefinity / Templates changing

Templates changing

2 posts, 0 answered
  1. Anton Mernov
    Anton Mernov avatar
    110 posts
    Registered:
    03 Dec 2008
    16 Feb 2009
    Link to this post
    Hi guys,

    I have two templates: parent and child. My pages use by default parent template. How I can change (not manually) parent template on child for all pages?

    Thanks,
    Anton.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    16 Feb 2009
    Link to this post
    Hi Anton,

    Here is my approach for changing pages Template and Theme programmatically.

            // new instance of CmsManager 
            CmsManager manager = new CmsManager(); 
            // create a list of pages 
            IList ListOfPages = manager.GetPages(); 
            foreach (IPage mypage in ListOfPages) 
            { 
                IPage page = manager.GetPage(mypage.ID, true); 
                // get the template 
                IPageTemplate template = manager.GetTemplate("Default"); 
                // set the template for all pages 
                page.Staged.SetTemplate(template.ID, ""); 
                // save pages 
                manager.SavePage(mypage); 
            } 

    I hope this helps.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
2 posts, 0 answered