NEW FEATURE: Import Content to Dynamic Module

Posted by Community Admin on 05-Aug-2018 00:34

NEW FEATURE: Import Content to Dynamic Module

All Replies

Posted by Community Admin on 18-Mar-2013 00:00

I found this out the hard way.  Apparently there is a way to export content, but there is no way to import content into your dynamic module.  Please add this in the near future. 


Craig

Posted by Community Admin on 18-Mar-2013 00:00

Hi Craig,

Dynamic modules allow you to export module structures and import them to other modules. However, you do not export the content of the module, only the module itself - fields, type, structure. Can you elaborate a bit more on what you want to achieve? 

Regards,
Jen Peleva
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 18-Mar-2013 00:00

Thanks for the reply Jen.

Specifically I would like the ability to export the CONTENT from a dynamic module and then IMPORT the content into another Sitefinity environment of the same dynamic module.  

For example, if I am building out a new dynamic module and I have entered the content in my TEST instance but now I want to move that content to my PROD instance.  I would then export the content and then import it into into the same module in my production environment.

As I think about this process, it seems bigger that what I first thought, but I also heard that Site Sync will soon have the capability to sync dynamic module content.  Too bad we would need Site Sync to do this though.  Thanks and have a great day.


Craig

Posted by Community Admin on 21-Mar-2013 00:00

This is really important. You can export custom module content, but you can't import it? Ouch.

I haven't taken a survey or anything but I would wager a guess that the 90% of module content export scenarios are people preparing to take something from sandbox to production.

Some kind of generic SiteFinity data import/export tool wrapped in a wizard interface would be nice right about now.

Posted by Community Admin on 21-Mar-2013 00:00

Hi guys,

At the moment we have planned syncing dynamic modules, which will practically provide this functionality. 

Greetings,
Jen Peleva
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 21-Mar-2013 00:00

Thank you for the reply. Look forward to using that functionality.

Posted by Community Admin on 21-Mar-2013 00:00

That's awesome, but this functionality is only available in the Site Sync Add-on which is a $2000 to $4000 add-on for Professional Edition users and up.  Is it possible to add a scaled down version specific for this one use case?

Thanks,
Craig

Posted by Community Admin on 25-Mar-2013 00:00

Hello Craig,

Someone from our Sales team will contact you shortly to give you more indormation about the Site Sync module.  

All the best,
Jen Peleva
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 28-Mar-2013 00:00

I agree there should be a content import if there's an export - included in any version.

Posted by Community Admin on 01-Apr-2013 00:00

Hi James,

The reason we haven't invested time in such functionality is that soon the ability to sync dynamic modules will be available out-of-the-box.

Kind regards,
Jen Peleva
the Telerik team

Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 09-May-2013 00:00

In case anyone else is trying to Import data exported from a Dynamic module, here is what I used. 

The code below creates a page that allows you to upload an excel file to import data from.

  • You will need to customize the key value section to match your data. 
  • You can find the field information for adding an item to your module by logging into the back end of your site and going to Module Builder>Your Module> and clicking "Code reference for 'Your Module'", and then look at the "Create a ..." code sample.
  • I have only used this for one module so I'm not sure how it will perform with other data structures.
  • I suppose you could use this process to import any data as long as it fit your schema.
Import_Module_Data.aspx
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Import_Module_Data.aspx.vb" Inherits="SitefinityWebAppVB.WebForm2" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <br />
        <br />
        This screen is used to import an excel file that is created when exporting data from the Consultant module.
        <br />
        <br />
        <asp:FileUpload ID="FileUpload1" runat="server" />  <asp:Button ID="btnGo" runat="server" Text="Import Data" />
        <br />
        <br />
        <br />
        <asp:Label ID="labelDone" runat="server"></asp:Label>
        <br />
        <asp:GridView ID="GridView1" runat="server">
</asp:GridView>
    </div>
    </form>
</body>
</html>


Import_Module_Data.aspx.designer.vb
'------------------------------------------------------------------------------
' <auto-generated>
'     This code was generated by a tool.
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------
 
Option Strict On
Option Explicit On
 
 
Partial Public Class WebForm2
 
    '''<summary>
    '''form1 control.
    '''</summary>
    '''<remarks>
    '''Auto-generated field.
    '''To modify move field declaration from designer file to code-behind file.
    '''</remarks>
    Protected WithEvents form1 As Global.System.Web.UI.HtmlControls.HtmlForm
 
    '''<summary>
    '''FileUpload1 control.
    '''</summary>
    '''<remarks>
    '''Auto-generated field.
    '''To modify move field declaration from designer file to code-behind file.
    '''</remarks>
    Protected WithEvents FileUpload1 As Global.System.Web.UI.WebControls.FileUpload
 
    '''<summary>
    '''btnGo control.
    '''</summary>
    '''<remarks>
    '''Auto-generated field.
    '''To modify move field declaration from designer file to code-behind file.
    '''</remarks>
    Protected WithEvents btnGo As Global.System.Web.UI.WebControls.Button
 
    '''<summary>
    '''labelDone control.
    '''</summary>
    '''<remarks>
    '''Auto-generated field.
    '''To modify move field declaration from designer file to code-behind file.
    '''</remarks>
    Protected WithEvents labelDone As Global.System.Web.UI.WebControls.Label
 
    '''<summary>
    '''GridView1 control.
    '''</summary>
    '''<remarks>
    '''Auto-generated field.
    '''To modify move field declaration from designer file to code-behind file.
    '''</remarks>
    Protected WithEvents GridView1 As Global.System.Web.UI.WebControls.GridView
End Class


Import_Module_Data.aspx.vb
Imports Telerik.Sitefinity
Imports Telerik.Sitefinity.Model
Imports Telerik.Sitefinity.DynamicModules
Imports Telerik.Sitefinity.Data.Linq.Dynamic
Imports Telerik.Sitefinity.DynamicModules.Model
Imports Telerik.Sitefinity.GenericContent.Model
Imports Telerik.Sitefinity.Utilities.TypeConverters
Imports Telerik.Sitefinity.Security
Imports Telerik.Sitefinity.Lifecycle
 
Imports Telerik.Sitefinity.Taxonomies
Imports Telerik.Sitefinity.Taxonomies.Model
Imports Telerik.Sitefinity.Modules.Libraries
 
Imports System.IO
Imports System.Data.OleDb
Imports System.Data
 
Public Class WebForm2
    Inherits System.Web.UI.Page
 
    Public Sub CreateConsultantListing(ByVal dtData As DataTable)
 
        ' Set the provider name for the DynamicModuleManager here. All available providers are listed in
        ' Administration -> Settings -> Advanced -> DynamicModules -> Providers
        Dim providerName As String = String.Empty
        Dim dynamicModuleManager_ As DynamicModuleManager = DynamicModuleManager.GetManager(providerName)
        Dim consultantListingType As Type = TypeResolutionService.ResolveType("Telerik.Sitefinity.DynamicTypes.Model.ConsultantDirectory.ConsultantListing")
        'Dim consultantListingItem As DynamicContent = dynamicModuleManager_.CreateDataItem(consultantListingType)
        Dim consultantListingItem As DynamicContent
 
        For Each rowConsultant As DataRow In dtData.Rows
            With rowConsultant
                consultantListingItem = dynamicModuleManager_.CreateDataItem(consultantListingType)
                ' This is how values for the properties are set
                consultantListingItem.SetString("UrlName", .Item("UrlName").ToString)
                consultantListingItem.SetValue("Company", .Item("Company").ToString)
                consultantListingItem.SetValue("Owner", SecurityManager.GetCurrentUserId())
                consultantListingItem.SetValue("PublicationDate", DateTime.Now)
                consultantListingItem.SetValue("Address1", .Item("Address1").ToString)
                consultantListingItem.SetValue("Address2", .Item("Address2").ToString)
                consultantListingItem.SetValue("City", .Item("City").ToString)
                consultantListingItem.SetValue("State", .Item("State").ToString)
                consultantListingItem.SetValue("Zip", .Item("Zip").ToString)
                consultantListingItem.SetValue("Phone", .Item("Phone").ToString)
            End With
 
            consultantListingItem.SetWorkflowStatus(dynamicModuleManager_.Provider.ApplicationName, "Draft")
 
            ' You need to call SaveChanges() in order for the items to be actually persisted to data store
            dynamicModuleManager_.SaveChanges()
        Next
 
        labelDone.Text = "Data has been imported."
    End Sub
 
    Public Sub ImportData()
        Dim connectionString As String = ""
        If FileUpload1.HasFile Then
            Dim strfileName As String = Path.GetFileName(FileUpload1.PostedFile.FileName)
            Dim strfileExtension As String = Path.GetExtension(FileUpload1.PostedFile.FileName)
            Dim strfileLocation As String = Server.MapPath("~/App_Data/" & strfileName)
            'This will delete an old file if it exists.
            File.Delete(strfileLocation)
            If File.Exists(strfileLocation) = False Then
                FileUpload1.SaveAs(strfileLocation)
            End If
 
            'Check whether file extension is xls or xslx
            If strfileExtension = ".xls" Then
                connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strfileLocation & ";Extended Properties=""Excel 8.0;HDR=Yes;IMEX=2"""
            ElseIf strfileExtension = ".xlsx" Then
                connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & strfileLocation & ";Extended Properties=""Excel 12.0;HDR=Yes;IMEX=2"""
            End If
 
            'Create OleDB Connection and OleDb Command
 
            Dim con As New OleDbConnection(connectionString)
            Dim cmd As New OleDbCommand()
            cmd.CommandType = System.Data.CommandType.Text
            cmd.Connection = con
            Dim dAdapter As New OleDbDataAdapter(cmd)
            Dim dtExcelRecords As New DataTable()
            con.Open()
            Dim dtExcelSheetName As DataTable = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, Nothing)
            Dim strgetExcelSheetName As String = dtExcelSheetName.Rows(0)(2).ToString()
            cmd.CommandText = "SELECT * FROM [" & strgetExcelSheetName & "]"
            dAdapter.SelectCommand = cmd
            dAdapter.Fill(dtExcelRecords)
            con.Close()
            GridView1.DataSource = dtExcelRecords
            GridView1.DataBind()
 
 
            'Import records
            CreateConsultantListing(dtExcelRecords)
        End If
    End Sub
 
    Private Sub btnGo_Click(sender As Object, e As System.EventArgs) Handles btnGo.Click
        Try
            ImportData()
        Catch ex As Exception
            labelDone.Text = "Data was not imported."
        End Try
    End Sub
End Class

Posted by Community Admin on 13-May-2013 00:00

Hi Jeremy,

 Thank you for sharing your implementation with us!

All the best,
Jen Peleva
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

Posted by Community Admin on 12-Sep-2014 00:00

This thread is over a year old...I thought I'd check to see if this functionality has been added to Sitefinity? Or am I going to have to wade through this code with my very limited skills to figure out how to import some data into our modules? If I am going to have to is there a c# version anywhere of the great code Jeremy provided? Thanks!

Posted by Community Admin on 17-Sep-2014 00:00

Hello Richard,

Currently, this functionality is not available out of the box. We have a feature request logged in our feedback portal to allow users to import data to their dynamic modules. Hopefully we will be able to implement it in the near future. Here is a link to the feedback portal where you can track the progress of the feature request and vote to increase its popularity.

For the time being, you may take a look at the following article for more details on importing external data to Sitefinity dynamic modules. 

Regards,
Sabrie Nedzhip
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 09-Mar-2015 00:00

Hi. Is there any progress on this feature being made available out of the box? It is really a critical requirement for many large content websites.

Posted by Community Admin on 12-Mar-2015 00:00

Hello,

This feature is still not available out of the box. For the time being the only option is to import the content using custom logic as described in the suggested blog post.

Regards,
Sabrie Nedzhip
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

Posted by Community Admin on 01-Jul-2015 00:00

The ability to define custom content data models is useful in theory but if in practice you have to commandeer a DBA for a few hours or crack open a SQL client just to migrate content into your custom data model it really defeats the purpose of the feature.

This thread is closed