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

Forums / Designing with Sitefinity / Duplicate Master Page Editing

Duplicate Master Page Editing

4 posts, 0 answered
  1. David Jones
    David Jones avatar
    3 posts
    Registered:
    03 Nov 2009
    27 Jan 2010
    Link to this post
    I used the 'duplicate' master page option from the admin to create my primary master page. This new master page does not appear to be a 'physical' page that can be edited in VS? Is there any way to 'save' this master page as a template that can be edited in Visual Studio?
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    27 Jan 2010
    Link to this post
    Hi David Jones,

    Thank you for using our services.

    Unfortunately there is no such option yet. When you generate a master page it creates another instance of it in the database, not a physical file. The only option would be to just copy/paste the physical file in VS.

    All the best,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
  3. David Jones
    David Jones avatar
    3 posts
    Registered:
    03 Nov 2009
    27 Jan 2010
    Link to this post
    Is there any way to go into 'code' view of the duplicated master page to copy and paste into a physical file in VS? Or am I just stuck rebuilding the entire master page in order to edit in VS from scratch?
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    27 Jan 2010
    Link to this post
    Hi David Jones,

    What you can do is:
    1) Open your website in VS and go to ~/App_Master
    2)Lets say that you want to duplicate ~/App_Master/Default.master and create a second version of it - ~/App_Master/Default2.master. After you have duplicated the physical file restart the website and Sitefinity will automatically detect it as a template.
    3) You can use Sitefinity's API to get both templates - the original one and the new one and put the same controls on it.

    CmsManager cmsManager = new CmsManager();
    IPageTemplate originalTemplate = cmsManager.GetTemplate("Default");
    IPageTemplate copyTemplate = cmsManager.GetTemplate("Default2");
    IPageTemplate copyTemplateForEdit = cmsManager.GetTemplate(copyTemplate.ID,true);
    copyTemplateForEdit.Staged.Theme = originalTemplate.Theme;
     
    foreach (var control in originalTemplate.Staged.Controls)
    {
        if (!copyTemplateForEdit.Staged.Controls.Contains(control))
        {
            copyTemplateForEdit.Staged.AddControl(control.ContainerID, control);
        }
    }
    cmsManager.SaveTemplate(copyTemplateForEdit);


    Regards,
    Radoslav Georgiev
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Register for webinar
4 posts, 0 answered