This project is read-only.

Import Export module can't export data added by Classy module?

Topics: Customizing Orchard, Troubleshooting, Writing modules
Aug 11, 2011 at 12:14 PM
Edited Aug 11, 2011 at 12:35 PM

Hi everyone.

I'm trying to create recipe using Import Export module to copy all data from one Orchard installation (local) to another (production)

Everything works correctly, except one quite annoying problem I'm facing.

I'm using Classy module to add some CSS classes and JS scripts to my pages.

When I'm exporting metadata and data using Import Export module, it seems that it can't extract data stored in CustomCss part of Classy module

I've checked XML produced as result of exporting, and I dont see any data related to CustomCss part there.

I even tried to add it myself, and then import that file, but data dont want to be imported.

Am i trying to do something which is not supported at all?

I've added CustomCss item manually to Page element, but it did not worked. This is my recipe which I'm trying to use


<!--Exported from Orchard-->
    <Name>Generated by Orchard.ImportExport</Name>
    <Page Id="/Route.Slug=contact-us" Status="Published">
      <BodyPart />
      <CommonPart Owner="/User.UserName=admin" CreatedUtc="2011-08-02T07:04:59Z" PublishedUtc="2011-08-05T13:51:35Z" ModifiedUtc="2011-08-05T13:51:35Z" />
      <MenuPart MenuPosition="7" OnMainMenu="false" />
      <RoutePart Title="Contact Us" Slug="contact-us" Path="contact-us" />
      <TagsPart Tags="" />
      <CustomCss CssClass="default contact-us" CustomId="" Scripts=""/>


Is there any workaround for this?

Aug 11, 2011 at 6:51 PM

Each module has to ensure that the import/export is handled. And I might assume it's not the case for this one. You might want to add the corresponding methods on a Fork on the module, or your local source copy, and make a pull request to the author (Bertrand).

Aug 12, 2011 at 3:17 AM

Well, I tried to investigate this problem by checking Classy module and ImportExport module source codes, and I did not found what exactly needs to be added to Classy module so it will support Importing and Exporting.

I've checked another module - Tags, which appears to create it's XML element correctly, and do not found anything specific to import/export in it's code.

Can you please point me in right direction, e.g. what needs to be added to Classy module so it will start working with Import/Export


Aug 12, 2011 at 4:31 AM

Sure, in Drivers you should find some examples of Import and Export overrides.

Aug 16, 2011 at 9:23 AM

Thanks Sebastien for your help. I was able to modify Classy source code to make it work in Import/Export module.

I just added these 2 overrides to CustomCssDriver class - I guess it might be good idea to release new version of Classy module so it will work with Import/Export as expected

protected override void Importing(CustomCss part, Orchard.ContentManagement.Handlers.ImportContentContext context)
            //base.Importing(part, context);

            var cssClass = context.Attribute(part.PartDefinition.Name, "CssClass");

            if(!string.IsNullOrEmpty(cssClass)) {
                part.CssClass = cssClass;

            var customId = context.Attribute(part.PartDefinition.Name, "CustomId");

            if (!string.IsNullOrEmpty(customId))
                part.CustomId = customId;

            var scripts = context.Attribute(part.PartDefinition.Name, "Scripts");

            if (!string.IsNullOrEmpty(scripts))
                part.Scripts = scripts;

        protected override void Exporting(CustomCss part, Orchard.ContentManagement.Handlers.ExportContentContext context)
            //base.Exporting(part, context);

            context.Element(part.PartDefinition.Name).SetAttributeValue("CssClass", part.CssClass);
            context.Element(part.PartDefinition.Name).SetAttributeValue("CustomId", part.CustomId);
            context.Element(part.PartDefinition.Name).SetAttributeValue("Scripts", part.Scripts);

Aug 16, 2011 at 6:55 PM

You need to post it to its specific website, which is not part of Orchard's core modules, but a contribution from Bertrand Leroy