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

Forums / Developing with Sitefinity / Loading Pages from another CMS

Loading Pages from another CMS

13 posts, 0 answered
  1. Julian
    Julian avatar
    4 posts
    Registered:
    04 May 2008
    12 May 2008
    Link to this post
    We have an old production CMS that I need to migrate to SiteFinity, the old cms has a simple data model, basically Category and PageContent.

    Can I insert the pages into the database easily ?

    I have profiled the sql server and there seems to be a lot dependencies. I would be just inserting the PageContent into a "Generic Content" control

    There are 5000 pages to load in.


  2. Joe
    Joe avatar
    64 posts
    Registered:
    05 Jul 2012
    13 May 2008
    Link to this post
    You would have to write a control to import the data.  If you want to import the previous 5000 CMS pages into Sitefinity as individual pages you would use the Telerik.Cms.CmsManager object with the CreatePage method.  If you want them to be just generic content look at the Telerik.Cms.Engine.ContentManager namespace.

    Joseph Guadagno
    http://www.sevdnug.org
  3. Julian
    Julian avatar
    4 posts
    Registered:
    04 May 2008
    14 May 2008
    Link to this post

    Thanks Joseph for pointing me in the right direction...

    I found some sample code but I am  having a problem setting the template for the new page.. and ideas why I get "Unable to cast object of type 'Telerik.Cms.Data.CmsTemplateContent' to type 'Telerik.Cms.Data.PageTemplate'."  when I try set the template



    Code:

    CmsManager
    manager = new CmsManager();

    ICmsPage userPage = manager.CreatePage("admin");

    userPage.Navigable = true;

    userPage.MenuName = "TestCreate3";

    userPage.Staged.Template = manager.GetTemplate("MyMaster");

    //Above fails

    userPage.Publish();

  4. Vlad
    Vlad avatar
    498 posts
    Registered:
    15 Jul 2016
    14 May 2008
    Link to this post
    Hi Julian,

    Probably the better approach could be to use the Import() function of the CmsProvider:

    DataSet dataSet = new DataSet(); 
    dataSet.ReadXml("Path_to_xml_file", XmlReadMode.ReadSchema); 
    CmsManager manager = new CmsManager(); 
    manager.Provider.Import(dataSet); 
     

    ... which requires DataSet parameter. If you are able to generate a DataSet object from another CMS and save it in an XML file, you can then import it into Sitefinity. Here is the scheme of the DataSet:

      <xs:schema id="Sitefinity" xmlns="" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"
        <xs:element name="Sitefinity" msdata:IsDataSet="true" msdata:UseCurrentLocale="true"
          <xs:complexType> 
            <xs:choice minOccurs="0" maxOccurs="unbounded"
              <xs:element name="Pages"
                <xs:complexType> 
                  <xs:sequence> 
                    <xs:element name="ID" msdata:DataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs:string" minOccurs="0" /> 
                    <xs:element name="ParentID" msdata:DataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs:string" minOccurs="0" /> 
                    <xs:element name="Name" type="xs:string" minOccurs="0" /> 
                    <xs:element name="Navigable" type="xs:boolean" minOccurs="0" /> 
                    <xs:element name="DenyAnonymous" type="xs:boolean" minOccurs="0" /> 
                    <xs:element name="RequireCaching" type="xs:boolean" minOccurs="0" /> 
                    <xs:element name="RequireSSL" type="xs:boolean" minOccurs="0" /> 
                    <xs:element name="PageType" type="xs:int" minOccurs="0" /> 
                    <xs:element name="ExternalUrl" type="xs:string" minOccurs="0" /> 
                    <xs:element name="Ordinal" type="xs:int" minOccurs="0" /> 
                  </xs:sequence> 
                </xs:complexType> 
              </xs:element> 
              <xs:element name="PageContents"
                <xs:complexType> 
                  <xs:sequence> 
                    <xs:element name="ID" msdata:DataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs:string" minOccurs="0" /> 
                    <xs:element name="LangID" type="xs:int" minOccurs="0" /> 
                    <xs:element name="MenuName" type="xs:string" minOccurs="0" /> 
                    <xs:element name="TemplateID" msdata:DataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs:string" minOccurs="0" /> 
                    <xs:element name="MasterPage" type="xs:string" minOccurs="0" /> 
                    <xs:element name="Theme" type="xs:string" minOccurs="0" /> 
                    <xs:element name="Title" type="xs:string" minOccurs="0" /> 
                    <xs:element name="Description" type="xs:string" minOccurs="0" /> 
                    <xs:element name="Keywords" type="xs:string" minOccurs="0" /> 
                  </xs:sequence> 
                </xs:complexType> 
              </xs:element> 
              <xs:element name="Controls"
                <xs:complexType> 
                  <xs:sequence> 
                    <xs:element name="ID" msdata:DataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs:string" minOccurs="0" /> 
                    <xs:element name="PageID" msdata:DataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs:string" minOccurs="0" /> 
                    <xs:element name="Name" type="xs:string" minOccurs="0" /> 
                    <xs:element name="TypeName" type="xs:string" minOccurs="0" /> 
                    <xs:element name="ContainerID" type="xs:string" minOccurs="0" /> 
                    <xs:element name="IsAscx" type="xs:boolean" minOccurs="0" /> 
                    <xs:element name="Ordinal" type="xs:int" minOccurs="0" /> 
                  </xs:sequence> 
                </xs:complexType> 
              </xs:element> 
              <xs:element name="ControlProperties"
                <xs:complexType> 
                  <xs:sequence> 
                    <xs:element name="ControlID" msdata:DataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs:string" minOccurs="0" /> 
                    <xs:element name="Name" type="xs:string" minOccurs="0" /> 
                    <xs:element name="Value" type="xs:string" minOccurs="0" /> 
                    <xs:element name="ParentID" msdata:DataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs:string" minOccurs="0" /> 
                    <xs:element name="ParentName" type="xs:string" minOccurs="0" /> 
                  </xs:sequence> 
                </xs:complexType> 
              </xs:element> 
              <xs:element name="PagePermissions"
                <xs:complexType> 
                  <xs:sequence> 
                    <xs:element name="PageID" msdata:DataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs:string" minOccurs="0" /> 
                    <xs:element name="Role" type="xs:string" minOccurs="0" /> 
                    <xs:element name="Grant" type="xs:int" minOccurs="0" /> 
                    <xs:element name="Deny" type="xs:int" minOccurs="0" /> 
                  </xs:sequence> 
                </xs:complexType> 
              </xs:element> 
              <xs:element name="GlobalPermissions"
                <xs:complexType> 
                  <xs:sequence> 
                    <xs:element name="Role" type="xs:string" minOccurs="0" /> 
                    <xs:element name="Grant" type="xs:int" minOccurs="0" /> 
                    <xs:element name="Deny" type="xs:int" minOccurs="0" /> 
                  </xs:sequence> 
                </xs:complexType> 
              </xs:element> 
              <xs:element name="Templates"
                <xs:complexType> 
                  <xs:sequence> 
                    <xs:element name="ID" msdata:DataType="System.Guid, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" type="xs:string" minOccurs="0" /> 
                    <xs:element name="Name" type="xs:string" minOccurs="0" /> 
                    <xs:element name="MasterPage" type="xs:string" minOccurs="0" /> 
                    <xs:element name="Theme" type="xs:string" minOccurs="0" /> 
                  </xs:sequence> 
                </xs:complexType> 
              </xs:element> 
              <xs:element name="Variables"
                <xs:complexType> 
                  <xs:sequence> 
                    <xs:element name="Name" type="xs:string" minOccurs="0" /> 
                    <xs:element name="Value" type="xs:string" minOccurs="0" /> 
                  </xs:sequence> 
                </xs:complexType> 
              </xs:element> 
            </xs:choice> 
          </xs:complexType> 
        </xs:element> 
      </xs:schema> 

    As a example, we attached the CmsPages.xml file used by Company site template for importing pages. Also, you could use an Export() function of the CmsProvider to generate a similar file for your existing Sitefinity project.

    Greetings,
    Vlad
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Theo
    Theo avatar
    2 posts
    Registered:
    16 Dec 2008
    16 Dec 2008
    Link to this post
    I found this post useful. We have an Eprise CMS we would like to port over to Sitefinity.

    It would be very cool if you could add documentation or a tutorial to the formal sitefinity docs about importing data in from other CMS's.

    That would make our life easier to try to sell sitefinity to replace other CMS's. Everybody always wonders how migration is going to work.
  6. Elizabeth
    Elizabeth avatar
    83 posts
    Registered:
    23 Mar 2005
    16 Dec 2008
    Link to this post
    I agree - we are starting to look at other systems to replace our Microsoft CMS system and one of the big tasks would be importing the existing pages into a new system.
  7. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    17 Dec 2008
    Link to this post
    Hello,

    We noticed this suggestion, and will surely think about it!
    As for the main question here, it really depends on from what platform you are migrating. You can use our CmsManager APIs to create pages as the demo below, but it will be up to you how you will take the content.

    A good solution could for example, if your current portal or cms provides RSS for your pages. You can take the content from this feed, as the contents come formatted.

    Sincerely yours,
    Georgi
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  8. Kurt
    Kurt avatar
    7 posts
    Registered:
    31 Aug 2006
    03 Mar 2010
    Link to this post
    Was the orginal issue reporetd in this thread ever fixed, eg: Unable to cast object of type 'Telerik.Cms.Data.CmsTemplateContent' to type 'Telerik.Cms.Data.PageTemplate'.

    It really seems like this should work?

     ICmsPage newSFPage = manager.CreatePage(raySection.SectionName);
                //setting the template causes the exception..
                newSFPage.Staged.Template = rayOneColTempate;
                //this way too..
                //newSFPage.Template = rayOneColTempate;
                newSFPage.Navigable = true;
                newSFPage.PageType = CmsPageType.Group;
                newSFPage.Publish();
  9. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    04 Mar 2010
    Link to this post
    Hello Kurt,

    Try using the code below

    IPage page = cmsManager.GetPage(cmsPage.ID, true);
      
    // get the template that this page will use
    IPageTemplate pageTemplate = cmsManager.GetTemplate("Default");
      
    // assign the template to the page and optionally the theme
    page.Staged.SetTemplate(pageTemplate.ID, string.Empty);
     
    // save the page
    cmsManager.SavePage(page);


    Greetings,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  10. payam
    payam avatar
    8 posts
    Registered:
    19 Jul 2012
    13 May 2010
    Link to this post
    hi

    i used the "SetTemplate" Method and it worked. My questions are :

    1- why setting the Template property throws the "Unable to cast exception"?
    2- why developer manual of sitefinity at Working with Pages Programmatically section uses the Template property to set the page template ?
    3 - why icmspage interface has the template property and it is not read only ?
    4 - what is the difference between icmspage.Template property and istagedpage.template property?

    thx
  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    14 May 2010
    Link to this post
    Hello payam,

    You can avoid "Unable to cast" exception by modifying the code as shown below

    msManager manager = new CmsManager();
    ICmsPage userPage = manager.CreatePage("userName11");
     
    userPage.Navigable = true;
    userPage.MenuName = "test";
    IPageTemplate temp = manager.GetTemplate("Default");
    userPage.Staged.Template = manager.GetTemplate(temp.ID);
    manager.SavePage(userPage);

    As you can see the property is not read only. The problem comes form the type that is used in the sample. The sample is obsolete. We are working on a new manual and will replace the old one.

    Anyway I believe that the samples there has cleared the situation and you can now set a template for a page.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  12. Elizabeth
    Elizabeth avatar
    83 posts
    Registered:
    23 Mar 2005
    13 Apr 2011
    Link to this post
    Any way to do this by scraping a site directly? We have sites that can't be exported into XML or any other format.
  13. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    13 Apr 2011
    Link to this post
    Hello Elizabeth,

    There is a built-in export tool under Administration that you can use to export small sites to XML.

    Greetings,
    Ivan Dimitrov
    the Telerik team

Register for webinar
13 posts, 0 answered