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

Forums / Designing with Sitefinity / Change ContentPlaceHolder ID

Change ContentPlaceHolder ID

6 posts, 0 answered
  1. Kwinten Volckaert
    Kwinten Volckaert avatar
    41 posts
    Registered:
    01 Mar 2005
    27 Sep 2007
    Link to this post
    Is there a way that I can rename the ID's of the contentplaceholder without retyping all the content. The names I had chosen are too long but there are allready a small 100 pages. Can I make a change in the name in the template and make some mass-update in the database???
  2. Slavo
    Slavo avatar
    295 posts
    Registered:
    24 Sep 2012
    27 Sep 2007
    Link to this post
    Hello Kwinten Volckaert,

    Yes, it is possible to rename a placeholder. First, give a new name to the placeholder in the .master file for your template. This is located in the App_Master folder in your project and has the name of your template. Then you have to make changes to two tables in the database:

    1. sf_CmsCtrlLinks table - In all rows that you see the old name of your placeholder in the ContainerID column, change it to the new name.

    2. sf_StagesCtrlLinks table - same as in the other table - change the old name to new name in ContainerID column.

    This would keep all controls that you have put in that placeholder in all pages of the application.

    Greetings,
    Slavo
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Kwinten Volckaert
    Kwinten Volckaert avatar
    41 posts
    Registered:
    01 Mar 2005
    27 Sep 2007
    Link to this post
    Shamefully I must admit I can't find sf_CmsCtrlLinks (or sf_CmsControlLink). Also in table sf_StagedControlLink (I'm guessing that's the name of the other table) I can find the ContainerID column, but in my templates some containerid names are the same, so I can't find the containers from on a specific template.
  4. Slavo
    Slavo avatar
    295 posts
    Registered:
    24 Sep 2012
    28 Sep 2007
    Link to this post
    Hi Kwinten Volckaert,

    It appears that the names of the tables have changed after version 3.0 SP1 and you are using an older version. The old names are as follows: sf_CmsWebControlLink and sf_StagedControlLink. You should change the old name of the placeholder in ContainerID column to the new name. Hope this solves your problem.

    Greetings,
    Slavo
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Laura
    Laura avatar
    311 posts
    Registered:
    25 Feb 2008
    27 Jan 2010
    Link to this post
    If I have a navigation control located in Sitefinity\UserControls\Navigation35, already placed on many, many templates in my site, and now I want to move the control to Custom\Controls\Navigation,  can I do that and just update the database manually, instead of deleting the control and placing the new one on the on each template?

    Thank you.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    27 Jan 2010
    Link to this post
    Hello Laura,

    You can create a simple code and loop through all ICmsPage object. Then cast the page to IStagedPage and remove the control. Afterwards add it again.

    var Manager = new CmsManager();
    IList pages = Manager.GetPages();
    foreach (ICmsPage cmsPage in pages)
    {
        if (cmsPage != null)
        {
            ICmsPage p = (ICmsPage)Manager.GetPage(cmsPage.ID, true);
            IStagedPage staged = p.Staged as IStagedPage;
            foreach (ICmsWebControl c in staged.Controls)
            {
                if (c.ControlType.Name == "SiteMenu")
                {
                    staged.RemoveControl(c);
                    p = (ICmsPage)Manager.GetPage(p.ID, true);
                    p.Publish();
                     
      
                    // HERE GET THE PAGE AGAIN AND ADD THE NEW Control again
                    staged.AddControl("YOUR HOLDER", "PATH TO YOUR USER CONTROL", "THE ID OF YOUR CONTROL");
                    Manager.SavePage(p);
     
                    break;
      
                }
            }
        }
    }


    Best wishes,
    Ivan Dimitrov
    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
6 posts, 0 answered