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

Forums / Developing with Sitefinity / Create projects from sites template with shared content of previous project

Create projects from sites template with shared content of previous project

16 posts, 0 answered
  1. Lio
    Lio avatar
    10 posts
    Registered:
    08 Jan 2009
    08 Jan 2009
    Link to this post
    Hi,

    We need to share contents between projects which use the same database with different application name.

    After we export the sites template to a zip file , we want to create another project using the template with same database but <cms> tag with a different applicationName as:
    <cms defaultProvider="Sitefinity" pageExtension=".aspx" pageEditorUIMode="Overlay" disabled="true" projectName="Palio" siteTemplate="PalominoTemplate">
          <providers>
            <clear />
            <add connectionStringName="DefaultConnection" allowPageHistory="true" allowPageWorkflow="false" name="Sitefinity" type="Telerik.Cms.Data.DefaultProvider, Telerik.Cms.Data" applicationName="DIFFENT_NAME" />
          </providers>

    We created project by Project Manager, and until "Import template data" step we got "Duplicate Primary Key Error".

    I would like to ask if we can ignore duplicated rows, and insert new rows with new applicationName or how do we create a project from sites template which will share the generic control with the previous project but different pages (the pages map in new project is the same with template, but they are not shared)

    Thank you.


  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    12 Jan 2009
    Link to this post
    Hello Lio,

    Thank you for using our services.

    Changing the applicationName attribute will allow you to hide the pages between your websites. However, to proceed on the next step, open the web.config file on the newly created project after it has been created through the Project Manager and change the applicationName attribute. Then, go to "Import template data"
    Thus, you will set the application name before importing the template and this should prevent the conflict with your database.

    Let us know if there are any problems.

    Regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  3. Lio
    Lio avatar
    10 posts
    Registered:
    08 Jan 2009
    13 Jan 2009
    Link to this post
    Hi Ivan,

    Thank you for your help, but I still got the problem.

    These are my steps:

    1. Export a sites template "LioTemplate.rar" from "Lio" project which currently has cms page with applicationName as "LioAppliction"

    2. Create a new project "LioNew" by project manager with "LioTemplate"

    3. Point LioNew's Database to Lio's database (MSSQL Server)

    4. Change the cms providers' applicationName (from the config file in LioNew) to LioNewApplication

    5. Import Data Template through project manager , and I've got the Error:

    Importing template data failed: Violation of PRIMARY KEY constraint 'PK_sf_CmsControlProperty'. Cannot insert duplicate key in object 'dbo.sf_CmsControlProperty'. The statement has been terminated.. Check the error log for more details.

    The other parts of database make conflict while I intent to import cms pages with new applicationName.

    Do you have any ideas about duplicating cms pages from one project to another with a new applicationName but still keeping sharing generic contents.

    Thank you very much for your help.

    Lio





     
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    13 Jan 2009
    Link to this post
    Hello Lio,

    Thanks for the steps.

    I imported a template to my local project and did not find any problems during exporting and importing. However, please follow the steps below and let me know about the result.

    1. Go to Administration tab of your Sitefinity project and export your template from the Tools->Export screen. By default the template is exported to ~\App_Data\Sitefinity_Exports

    2. Copy the template to ~\ProjectManager\Templates\ . After you have copied the template you should have \ProjectManager\Templates\YOUR_TEMPLATE_NAME_HERE\project.zip

    3. Then run the Project Manager, and after the physical files have been created, edit the web.config file with different applicationName="/YOUR_NEW_APP_NAME_HERE"

    4. Follow the steps.

    In this way you should not have any problems with the database. Let me know about the result.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  5. Lio
    Lio avatar
    10 posts
    Registered:
    08 Jan 2009
    14 Jan 2009
    Link to this post
    Hi Ivan,

    Just want to make sure that you are using MSSQL database server and the projects are pointed to the same database?

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    14 Jan 2009
    Link to this post
    Hi Lio,

    I am using MS SQL Server 2005. The connection string points to the same database, which I created. Let us know if there is anything else that we can do for you.

    Greetings,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  7. Lio
    Lio avatar
    10 posts
    Registered:
    08 Jan 2009
    14 Jan 2009
    Link to this post
    Hi Ivan,


    Thank you very much for your reply but I've still got the error as I described.

    When replacing the new applicationName, I replace only in <cms> tag and all others keep the same. Did you do this too?

    I have noticed that your steps are quite same as my steps.




  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    14 Jan 2009
    Link to this post
    Hi Lio,

    Please note that I am changing the web.config on step 3. Do you still get the same error? Have you copied the templates to ProjectManager/Templates/ folder?

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  9. Lio
    Lio avatar
    10 posts
    Registered:
    08 Jan 2009
    15 Jan 2009
    Link to this post
    Hi Ivan,

    At first I have done all steps as the post "Lio, 1/13/2009 12:51:30 AM".

    I describe my steps again:

    1. Create sites template from exporting, I have a "template.zip" file
    2. Copy to /ProjectManager/Templates
    3. Access to Sitefinity Project Manger by Web, create a new project (name: NewProject) and select the template which I notice a folder containing template.zip and web.config.xml in /ProjectManager/Templates/template is automatically created .

    4. After creating new project, I can see the project in the list of projects from Project manager and I notice a folder "NewProject" in SiteFinity/Websites/  , and a web.config in NewProject.

    5. In web.config, <cms> tag, I change the applicationName to a new applicationname.

    6. Go back to Project Manager, select edit. I select the database which point to the same database of my current project.

    7. Next, I was asked to import date template and I got the Error.

    I appricicate for your patience to help me and thank you.

    Lio



  10. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    16 Jan 2009
    Link to this post
    Hello Lio,

    Finally, I figured out what the problem is.
    it has to do with the sf_CmsControlProperty table ControlIDs and ParentIDs which are imported from a template. The problem is that the IDs are the same. This causes the error.  The table stores data for the settings of the control properties that have been added to a given page.

    The solution is to edit the CmsPages.xml file and set new Guids for ContolID and ParentID.
    The CmsPages.xml is located in the zipped template afer you have exported it from your website, in folder  ~\App_Data\Sitefinity_DataImport\TEMPLATE_NAME_HERE

    I am sending you code that will fix the problem. You should add it to a user control and run it. I ran the code on Button1_Click and specified the CmsPages.xml file to my local dir /XML .

    private void UpdatePropertiesRecursive(DataTable table, Guid oldParentID, Guid newParentID, string parentName) 
        { 
            DataRow[] rows = table.Select("ParentID='" + oldParentID + "' and ParentName = '" + parentName + "'"); 
            foreach (DataRow row in rows) 
            { 
                Guid oldID = (Guid)row["ControlID"]; 
                Guid newID = Guid.NewGuid(); 
                row["ControlID"] = newID; 
                row["ParentID"] = newParentID; 
     
                UpdatePropertiesRecursive(table, oldID, newID, (string)row["Name"]); 
            } 
        } 
     
        protected void Button1_Click(object sender, EventArgs e) 
        { 
            string xmlFilePath = HttpContext.Current.Server.MapPath("~/XML/CmsPages.xml"); 
            if (File.Exists(xmlFilePath)) 
            { 
                DataSet dataSet = new DataSet(); 
                dataSet.ReadXml(xmlFilePath, XmlReadMode.ReadSchema); 
     
                DataTable controlsTable = dataSet.Tables["Controls"]; 
                DataTable controlPropertiesTable = dataSet.Tables["ControlProperties"]; 
     
                foreach (DataRow row in controlsTable.Rows) 
                { 
                    Guid oldID = (Guid)row["ID"]; 
                    Guid newID = Guid.NewGuid(); 
                    row["ID"] = newID; 
     
                    DataRow[] childRows = controlPropertiesTable.Select("ControlID='" + oldID + "'"); 
                    foreach (DataRow childRow in childRows) 
                    { 
                        Guid oldControlID = (Guid)childRow["ControlID"]; 
                        childRow["ControlID"] = newID; 
                        UpdatePropertiesRecursive(controlPropertiesTable, oldControlID, newID, (string)childRow["Name"]); 
                    } 
                } 
     
                dataSet.WriteXml(xmlFilePath, XmlWriteMode.WriteSchema); 
            } 
     

    Let us know if the problem still persists after changing the guids.

    Kind regards,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  11. Lio
    Lio avatar
    10 posts
    Registered:
    08 Jan 2009
    19 Jan 2009
    Link to this post
    Hi Ivan,

    I have done your steps, the code works well but after that I get this error:

    Importing template data failed: Violation of PRIMARY KEY constraint 'PK_sf_GCMetaData'. Cannot insert duplicate key in object 'dbo.sf_GCMetaData'. The statement has been terminated.. Check the error log for more details.

    May we need to change some more tables?

    Regards,

    Lio
  12. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    19 Jan 2009
    Link to this post
    Hi Lio,

    This is related to the GenericContent metafields. If you do not want to have GenericContent items, you could remove generic_content.xml  from the project.zip file. Otherwise, you could change the applicationName for generic content items in your web.config file.

    Example:

    <cmsEngine defaultProvider="Generic_Content"
          <providers> 
            <clear /> 
            <add name="Generic_Content" applicationName="/Generic_Content_NEW" urlRewriteFormat="[Publication_Date]/[Name].aspx" urlDateTimeFormat="yy-MM-dd" urlWhitespaceChar="_" visible="True" defaultMetaField="Name" securityProviderName="" allowLocalization="False" allowVersioning="True" allowWorkflow="False" allowComments="false" commentsModeration="true" versioningProviderName="" connectionStringName="GenericContentConnection" type="Telerik.Cms.Engine.Data.Providers.DefaultProvider, Telerik.Cms.Engine.Data" /> 
            <add name="News" allowWorkflow="True" urlRewriteFormat="[Publication_Date]/[Title].aspx" urlDateTimeFormat="yy-MM-dd" urlWhitespaceChar="_" visible="False" defaultMetaField="Title" securityProviderName="" allowVersioning="True" applicationName="/NewsNEW" versioningProviderName="" commentsModeration="true" connectionStringName="GenericContentConnection" type="Telerik.News.Data.DefaultNewsProvider, Telerik.News.Data" /> 
            <add name="Blogs" allowWorkflow="True" urlRewriteFormat="[Publication_Date]/[Title].aspx" urlDateTimeFormat="yy-MM-dd" urlWhitespaceChar="_" visible="False" defaultMetaField="Title" applicationName="/BlogsNEW" allowVersioning="True" allowLocalization="False" localizationProviderName="" securityProviderName="" versioningProviderName="" connectionStringName="GenericContentConnection" type="Telerik.Blogs.Data.DefaultBlogProvider, Telerik.Blogs.Data" /> 
            <add name="Libraries" urlRewriteFormat="~/{Provider}/{LibraryName}/[Name].sflb.ashx" urlDateTimeFormat="yy-MM-dd" urlWhitespaceChar="_" visible="False" defaultMetaField="Name" applicationName="/LibrariesNEW" allowVersioning="False" allowLocalization="False" localizationProviderName="" allowWorkflow="False" securityProviderName="" versioningProviderName="" connectionStringName="GenericContentConnection" type="Telerik.Libraries.Data.DefaultProvider, Telerik.Libraries.Data" tagEditorTemplate="~/Sitefinity/Admin/ControlTemplates/Libraries/BatchTagsEditor.ascx" /> 
            <add name="Events" urlRewriteFormat="[Publication_Date]/[Title].aspx" urlDateTimeFormat="yy-MM-dd" urlWhitespaceChar="_" visible="False" defaultMetaField="Title" securityProviderName="" allowVersioning="True" applicationName="/EventsNEW" versioningProviderName="" commentsModeration="true" connectionStringName="GenericContentConnection" type="Telerik.Events.Data.DefaultEventsProvider, Telerik.Events.Data" /> 

    The changes above should fix the problem.

    Best wishes,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  13. Lio
    Lio avatar
    10 posts
    Registered:
    08 Jan 2009
    22 Jan 2009
    Link to this post
    Hi Ivan,

    My problem is finally solved.

    Thank you very much for your help in a long way.

    Regards,

    Lio
  14. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    22 Jan 2009
    Link to this post
    Hello Lio,

    I am glad to hear that everything is working now at your end. Let us know if there is anything else that we can do for you.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
  15. Richa
    Richa avatar
    69 posts
    Registered:
    04 Jun 2009
    31 Dec 2009
    Link to this post
    hi
    i exported a project which was in 3.6 and created a new one in 3.7 from this template.
    looks like it did not import tag data for news.
    are you aware of this issue or did i miss something?

    thanks
  16. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    04 Jan 2010
    Link to this post
    Hello Richa,

    Unfortunately Tags can not be exported in current versions of Sitefinity. You are not missing anything.

    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.
Register for webinar
16 posts, 0 answered