Importing / exporting templates and content

Jan 3, 2014 at 1:05 PM
Hi

I have a portal where 90% is 2sexy content and ranges from simple listings with only a few fields to the more complex ones of about 50 fields

Now i need to make a new parent portal and copy all the templates and content types to the other portal how can I do this.

Is there a way to import and export these so i don't have to recreate them all on the new portal install. I thought when i set it to to use the sme virtual db it would also have the content I made but that does nto seem to be the case

Any help would be appreciated

Armand
Coordinator
Jan 6, 2014 at 7:53 AM
We're working on import/export for the upcoming version 5.4. My guess is it should be done in about 14 days - it's rather complex because of Multilanguage, since often the exported language combinations don't match the imported combinations.

Best, Daniel
Jan 8, 2014 at 3:19 PM
Great will save me some work and allow for easier reuse
Jan 23, 2014 at 11:13 AM
Just installed 5.4. Thanks for the hyperlink type, that will help a lot and make the content editor very happy.

Unfortunately I did not see an announcement for import/export of templates. Will this be in another update?

Armand
Coordinator
Jan 23, 2014 at 1:31 PM
It’s in there. Raphael forgot to mention it, but it’s actually the biggest part :).
I mentioned it on the revised home on codeplex, but we’ll update the download page too. Blogs & Videos will follow!
Best,
Daniel
Jan 23, 2014 at 10:12 PM
Great I realy wanna try the export and import. Could not find it as menu item so looking forward to the instructions
Developer
Jan 29, 2014 at 7:13 AM
Armand, open the Admin menu and go to "Import Templates" (as of 5.4.1, this menu item will be called Import / Export). At the bottom beneath the import button, you will find Export (beta).

Raphael
Jan 30, 2014 at 7:15 PM
Great ill go and test it
Jan 31, 2014 at 11:36 PM
When I export a content type I see that there is the EntityGUID. If I wanted to add new fields and import the content type, do I leave the EntityGUID empty for the new fields?
Coordinator
Feb 3, 2014 at 7:54 AM
@RacerNerd: Your question is a bit vague since there are 3 systems involved: the source, the xml-file and the target. Could you add a few more details - like where you add fields and where you were considering leaving away GUIDs?

Note: I documented the general import process here - it might help some, but i'll be happy to extend the infos as needed.
Feb 6, 2014 at 7:01 PM
The exact place I am talking about is the XML file produced using the Export tool.
I am exporting a Content Type.

I figured I could export this file, modify it, add things to it, and import it to update the definition for the content type.
It would be faster to add a ton of fields by modifying the text file rather than using the GUI.

Here is the XML I get out that shows the EntityGUID attribute I refer to. I am not sure what this value should be if I am adding new fields to my Content type, or if I can add new fields using this technique at all.
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<SexyContent FileVersion="05.04.01" MinimumRequiredVersion="05.04.01" ModuleVersion="05.04.01" ExportDate="2014-02-06T10:54:34.7320636-08:00">
  <Header>
    <Language Default="en-US" />
    <Dimensions />
  </Header>
  <AttributeSets>
    <AttributeSet StaticName="17e8de6f-e58c-4551-90f1-c8972b86ebd5" Name="MY CONTENT TYPE NAME" Description="MY CONTENT TYPE">
      <Attributes>
        <Attribute StaticName="Name" Type="String" IsTitle="true">
          <Entity AssignmentObjectType="EAV Field Properties" AttributeSetStaticName="@All" AttributeSetName="@All" EntityGUID="9471569b-e175-4612-9a17-99079dbdb5d7">
            <Value Key="Name" Value="Name" Type="String" />
          </Entity>
        </Attribute>
        <Attribute StaticName="MainColor" Type="String" IsTitle="false">
          <Entity AssignmentObjectType="EAV Field Properties" AttributeSetStaticName="@All" AttributeSetName="@All" EntityGUID="14ba1363-0f39-48df-836c-9563653dfaec">
            <Value Key="Name" Value="MainColor" Type="String" />
          </Entity>
        </Attribute>
      </Attributes>
    </AttributeSet>
  </AttributeSets>
  <Entities />
  <Templates />
  <PortalFiles />
</SexyContent>
Coordinator
Feb 7, 2014 at 9:37 AM
This would work, but with some limitations
  • when importing an existing Content-Type, it will only add things. So anything you change will not be overwritten.
This is to protect yourself from the following scenario
  1. User imports a content-type...
  2. ...customizes it
  3. ...then imports an updated template-package, containing new templates etc.
So this way his customizations are preserved. At the moment you can't override this behavior, simply because the UIs to enable this would be very complex and only needed in very specific scenarios like yours.

General export/import documentation
Best,
Daniel
Feb 7, 2014 at 5:26 PM
Edited Feb 7, 2014 at 5:28 PM
This sounds good, but the statement about my case being a specific or complex scenario is incorrect.
In simple terms I have an existing content type and I want to add a new field to it. Forget changes, I don't need that.

From the documentation that I have read, and the answer above, it indicates adding fields is possible using import. I have not found a technically detailed description of how to do so and am hoping that my problems are just in the syntactic details.

In practice something is not working correctly when I try to add fields with the import feature and I am trying to figure out why.

I set up a "Test" Content type just for this. I isolated this to the easiest possible case, a Content type with a single string field. I wish to add a single string field to that existing content type with the name "Test".

When I use the export feature it gives me the following output:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<SexyContent FileVersion="05.04.01" MinimumRequiredVersion="05.04.01" ModuleVersion="05.04.01" ExportDate="2014-02-07T08:52:24.9676658-08:00">
  <Header>
    <Language Default="en-US" />
    <Dimensions />
  </Header>
  <AttributeSets>
    <AttributeSet StaticName="871ad5bb-60b4-41cc-8c8c-76884794722f" Name="Test" Description="Test">
      <Attributes>
        <Attribute StaticName="TestTitle" Type="String" IsTitle="true">
          <Entity AssignmentObjectType="EAV Field Properties" AttributeSetStaticName="@All" AttributeSetName="@All" EntityGUID="0cdaa54b-12ae-44f5-9245-3353590eeabb">
            <Value Key="Name" Value="TestTitle" Type="String" />
          </Entity>
        </Attribute>
      </Attributes>
    </AttributeSet>
  </AttributeSets>
  <Entities />
  <Templates />
  <PortalFiles />
</SexyContent>
I modify the xml to add another field with the name "TestTitle2" to this type.
Since I haven't found details, I intuitively create the following XML to add the field.
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<SexyContent FileVersion="05.04.01" MinimumRequiredVersion="05.04.01" ModuleVersion="05.04.01" ExportDate="2014-02-07T08:52:24.9676658-08:00">
  <Header>
    <Language Default="en-US" />
    <Dimensions />
  </Header>
  <AttributeSets>
    <AttributeSet StaticName="871ad5bb-60b4-41cc-8c8c-76884794722f" Name="Test" Description="Test">
      <Attributes>
        <Attribute StaticName="TestTitle" Type="String" IsTitle="true">
          <Entity AssignmentObjectType="EAV Field Properties" AttributeSetStaticName="@All" AttributeSetName="@All" EntityGUID="0cdaa54b-12ae-44f5-9245-3353590eeabb">
            <Value Key="Name" Value="TestTitle" Type="String" />
          </Entity>
        </Attribute>
        <Attribute StaticName="TestTitle2" Type="String" IsTitle="true">
          <Entity AssignmentObjectType="EAV Field Properties" AttributeSetStaticName="@All" AttributeSetName="@All">
            <Value Key="Name" Value="TestTitle2" Type="String" />
          </Entity>
        </Attribute>
      </Attributes>
    </AttributeSet>
  </AttributeSets>
  <Entities />
  <Templates />
  <PortalFiles />
</SexyContent>
When I import, an error shows up on the screen. The log file contains the following error:
[FATAL] DotNetNuke.Framework.PageBase - An error has occurred while loading page.
System.NullReferenceException: Object reference not set to an instance of an object.
   at ToSic.SexyContent.ImportExport.XmlImport.GetImportEntity(XElement xEntity, Int32 assignmentObjectTypeId, Nullable`1 keyNumber)
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at ToSic.SexyContent.ImportExport.XmlImport.GetImportEntities(IEnumerable`1 entities, Int32 assignmentObjectTypeId, Nullable`1 keyNumber)
   at ToSic.SexyContent.ImportExport.XmlImport.GetImportAttributeSets(IEnumerable`1 xAttributeSets)
   at ToSic.SexyContent.ImportExport.XmlImport.ImportXml(String xml)
   at ToSic.SexyContent.Import.ImportFromStream(Stream importStream, Boolean isZip)
   at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
2014-02-07 08:56:38,197 [COMPUTERNAME][Thread:62][ERROR] DotNetNuke.Services.Exceptions.Exceptions - ~/Default.aspx?tabid=217&error=Object+reference+not+set+to+an+instance+of+an+object.
System.NullReferenceException: Object reference not set to an instance of an object.
   at ToSic.SexyContent.ImportExport.XmlImport.GetImportEntity(XElement xEntity, Int32 assignmentObjectTypeId, Nullable`1 keyNumber)
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at ToSic.SexyContent.ImportExport.XmlImport.GetImportEntities(IEnumerable`1 entities, Int32 assignmentObjectTypeId, Nullable`1 keyNumber)
   at ToSic.SexyContent.ImportExport.XmlImport.GetImportAttributeSets(IEnumerable`1 xAttributeSets)
   at ToSic.SexyContent.ImportExport.XmlImport.ImportXml(String xml)
   at ToSic.SexyContent.Import.ImportFromStream(Stream importStream, Boolean isZip)
   at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
I have also attempted the import with the existing field excluded. I did this because I wanted to eliminate the chance that including it was being interpreted as a request for a change. It produced the same error.

I attempted the import with the Header section removed, same error.

I tried with the attribute "ExportDate" removed as it did not seem relevant to an import, it produced the same error.

I then modified the Entity tag to include an empty EntityGUID field and attempted an import. The tag was:
<Entity AssignmentObjectType="EAV Field Properties" AttributeSetStaticName="@All" AttributeSetName="@All" EntityGUID="">
This produced a different error saying that the GUID was in an unrecognized format. The exact error from the log is as follows:
[FATAL] DotNetNuke.Framework.PageBase - An error has occurred while loading page.
System.FormatException: Unrecognized Guid format.
   at System.Guid.GuidResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument, String failureArgumentName, Exception innerException)
   at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result)
   at System.Guid.Parse(String input)
   at ToSic.SexyContent.ImportExport.XmlImport.GetImportEntity(XElement xEntity, Int32 assignmentObjectTypeId, Nullable`1 keyNumber)
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at ToSic.SexyContent.ImportExport.XmlImport.GetImportEntities(IEnumerable`1 entities, Int32 assignmentObjectTypeId, Nullable`1 keyNumber)
   at ToSic.SexyContent.ImportExport.XmlImport.GetImportAttributeSets(IEnumerable`1 xAttributeSets)
   at ToSic.SexyContent.ImportExport.XmlImport.ImportXml(String xml)
   at ToSic.SexyContent.Import.ImportFromStream(Stream importStream, Boolean isZip)
   at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
2014-02-07 09:14:32,874 [COMPUTERNAME][Thread:24][ERROR] DotNetNuke.Services.Exceptions.Exceptions - ~/Default.aspx?tabid=217&error=Unrecognized+Guid+format.
System.FormatException: Unrecognized Guid format.
   at System.Guid.GuidResult.SetFailure(ParseFailureKind failure, String failureMessageID, Object failureMessageFormatArgument, String failureArgumentName, Exception innerException)
   at System.Guid.TryParseGuid(String g, GuidStyles flags, GuidResult& result)
   at System.Guid.Parse(String input)
   at ToSic.SexyContent.ImportExport.XmlImport.GetImportEntity(XElement xEntity, Int32 assignmentObjectTypeId, Nullable`1 keyNumber)
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at ToSic.SexyContent.ImportExport.XmlImport.GetImportEntities(IEnumerable`1 entities, Int32 assignmentObjectTypeId, Nullable`1 keyNumber)
   at ToSic.SexyContent.ImportExport.XmlImport.GetImportAttributeSets(IEnumerable`1 xAttributeSets)
   at ToSic.SexyContent.ImportExport.XmlImport.ImportXml(String xml)
   at ToSic.SexyContent.Import.ImportFromStream(Stream importStream, Boolean isZip)
   at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
I have gone through just about every permutation of test that I can think of and nothing seems to work.
What am I doing wrong and why won't this import add a field?
Coordinator
Feb 10, 2014 at 8:37 AM
Raphael can probably help a bit more, at least 2 bugs are obvious
  1. You can't have IsTitle true on multiple fields
  2. Try adding a made-up guid with a guid-generator [http://www.guidgenerator.com/]. The import-export wasn't meant for manual editing, so IDs and such are pretty important. If you would have added this field in another 2sexycontent and exported it, it would have a guid and this would be important on a upcoming re-import.
Feb 10, 2014 at 4:43 PM
Thanks, those two things did the trick.

I went back and tested with an empty GUID and it didn't work.
It would be nice if the GUID were automatically generated for new fields.