Skip to main content
Home  ›  Docs › Feature

Data Integration for Non-SQL data like RSS, Files, NoSQL etc.

Warning ⚠️: New Docs Available

These are old docs and we haven't found the time to completely move them. You will find comprehensive new docs on docs.2sxc.org.

Introduced in Version 06.00.06

In general the process is very, very easy:

  1. Construct a DataTable for the data
  2. Fill it with the data you want (for example, retrieved from an external RSS-Feed)
  3. Give the DataTable to the DataTableDataSource...
  4. ...and that's it

Download this Demo-App to give it a try, or look at the result here.

Code Sample

@using System.Data

@using ToSic.Eav.DataSources

@functions

{

       // Official place to provide data preparation. Is automatically called by 2SexyContent

       public override void CustomizeData()

       {

             var res = CreateResourcesSource();

             res.Source.Rows.Add(1031, "de-de", "Deutsch", "Herzlich Willkommen", "Schön, dass Sie dies lesen, bitte haben Sie Spass!", "Vorname", "Nachname");

             res.Source.Rows.Add(1033, "en-us", "English", "Welcome", "Thanks for looking at this!", "First name", "Last name");

             Data.In.Add(res.ContentType, res.Out["Default"]);

 

             // enable publishing

             Data.Publish.Enabled = true;

             Data.Publish.Streams = "Default,UIResources";

       }

 

       private DataTableDataSource CreateResourcesSource()

       {

             var dataTable = new DataTable();

             dataTable.Columns.AddRange(new[]

             {

                    new DataColumn("EntityId", typeof(int)),

                    new DataColumn("EntityTitle"),

                    new DataColumn("Language"),

                    new DataColumn("Title"),

                    new DataColumn("Introduction"),

                    new DataColumn("FirstNameLabel"),

                    new DataColumn("LastNameLabel")

             });

             var source = CreateSource<DataTableDataSource>();

             source.Source = dataTable;

             source.ContentType = "UIResources";

             //source.TitleField = "FullName"; // not necessary because we're already using the default

             //source.EntityIdField = "EntityId";// not necessary because we're already using the default

             return source;

       }

}

 

<div class="sc-element">

       @Content.Toolbar

       <h1>Simple Demo with custom data (for example to use non-SQL data)</h1>

       <p>This demo uses the 2sxc Pipeline (req. 2sxc 6.0.6+). More info <a href="http://2sexycontent.org/en-us/docsmanuals/feature.aspx?feature=2580" target="_blank">here</a>.</p>

       <h2>These entities resources are constructed by code</h2>

       <ol>

             @foreach (var resource in AsDynamic(Data.In["UIResources"]))

             {

                    //var resource = AsDynamic(eRes);

                    <li>@resource.EntityTitle - @resource.Title</li>

             }

       </ol>

</div>