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

Forums / Developing with Sitefinity / Mass replacing a control in sf pages using sql query

Mass replacing a control in sf pages using sql query

2 posts, 0 answered
  1. IH
    IH avatar
    11 posts
    Registered:
    13 Jan 2010
    15 Jan 2010
    Link to this post
    Hello,

    I have a website which have 100 pages all using the provided Breadcrumb control (used by pages not masterpages).

    Now I have created my own custom control off the provided Breadcrumb control to implement additional functionality.

    Unfortunately those 100 SF pages are still referencing to the old Breadcrumb (telerik's orignal) and I would like to replace them as I am aware that all the controls drawn on SF pages are stored in a DB table - I dont know which?

    Can you give me a sample query to mass replace:
    Telerik.Cms.Web.UI.Breadcrumb, Telerik.Cms.Web.UI 
     with
    MyCustomBreadcrumb, App_Code 
    In all SF pages in a website?

    Thanks
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    15 Jan 2010
    Link to this post
    Hello IH,

    You could try to work programmatically and delete the control from each page then add it again

    sample code

    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 == "BreadCrumb")
                {
                    staged.RemoveControl(c);
                    p = (ICmsPage)Manager.GetPage(p.ID, true);
                    p.Publish();
                    Manager.SavePage(p);
     
                    // HERE GET THE PAGE AGAIN AND ADD THE NEW BREADCRUMBCONTORL
                    break;
     
                }
            }
        }
    }


    Regards,
    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.
2 posts, 0 answered