This project is read-only.

Odd behavior with importing

Topics: Administration, General, Troubleshooting
Aug 29, 2011 at 7:45 PM

We have a site setup where the post slug handles hierarchy, so:

So article1's page is: for-the-media/article1 and article2's page is for-the-media/article2.  We're trying to take content from another site and import it into our side, and we have an import xml file created that handles this, but when we run it, it skips most of the items.  For instance, take the following XML file:

<!--Exported from Orchard-->
    <Name>Generated by a custom Joomla export script</Name>
  <Article Id="/Route.Slug=for-the-media/article1" Status="Published">
      <CommonPart Owner="/User.UserName=admin" CreatedUtc="2006-10-02T14:06:27Z" PublishedUtc="2006-10-02T14:00:43Z" ModifiedUtc="2009-01-26T19:45:58Z" />
      <BodyPart Text="Some text1" />
      <MenuPart MenuText="Article1" MenuPosition="0" OnMainMenu="false" />
      <RoutePart Title="Article1" Slug="for-the-media/article1" Path="for-the-media/article1" />
      <TagsPart Tags="" />
	<Article Id="/Route.Slug=for-the-media/article2" Status="Published">
      <CommonPart Owner="/User.UserName=admin" CreatedUtc="2006-10-02T14:06:27Z" PublishedUtc="2006-10-02T14:00:43Z" ModifiedUtc="2009-01-26T19:45:58Z" />
      <BodyPart Text="Some text2" />
      <MenuPart MenuText="Article2" MenuPosition="0" OnMainMenu="false" />
      <RoutePart Title="Article2" Slug="for-the-media/article2" Path="for-the-media/article2" />
      <TagsPart Tags="" />

When I attempt to import this via the orchard import module, it only pulls in article2.  If I do a search and replace on this XML and remove "for-the-media/" from all the spots, it pulls both of them in.  Is there something going on with the / in the post slug that could be throwing this out of whack?

Aug 29, 2011 at 7:49 PM

Very weird. If you have three articles, will it import only the last one?

Aug 29, 2011 at 7:50 PM

Is it splitting on slashes or something and checking for unicity? I used the above example, but added a unique number to each and it imported them both. e.g.,



Aug 29, 2011 at 7:51 PM

It's almost like the base "for-the-media" needs to be unique, or it skips it. I'll have to test this theory more, but it seems like that's the case...

Aug 29, 2011 at 7:58 PM
Edited Aug 29, 2011 at 7:58 PM

Ah, I think I see what's going on. The Id really is a list of things, and those things are separated by slashes. So in the id, you need to escape the slash that is inside theslug value (only in the Id attribute). I think you can use a backslash slash ("\/") instead of the slash (see contentidentity.cs).

Aug 29, 2011 at 8:02 PM

Awesome, that worked...that has been driving me nuts all day, so thank you for that.  2 questions:

1.) Why is the Id a list of things? What is that used for? When I do an export, it seems to always just be the same as the post slug/path

2.) What is the difference between slug and path for the routepart?

Aug 29, 2011 at 8:17 PM

Ah, that is a very interesting question. In an import/export, ids are problematic because they are relatively meaningless in themselves (they just need to be consistent and unique), but you need them. You can't use the id of the content item because that is only locally meaningful. The target may have another item with the same id already. So you need something that is meaningful and that does identify uniquely that item. It also needs to be consistent so that if you import twice, you don't get doubled items, and if you import an update, it updates instead of creating new items. If your content item is routable, the path is a good identifier, but not all content items are routable (widgets aren't for example). So we made this all pluggable so that identity providers can be added, and there may be more than one provider for any given item, for all we know. We took a page from the design of directory systems and use a composite id.

I think slug there is no difference here because these items don't have a container, but if they did, the slug would be relative to the container whereas the path would be the whole thing.

Dec 21, 2011 at 10:35 AM

I have create custom contentpart  with router part, i have check  databse table , title and slug is there, but path is null, why that?

Dec 21, 2011 at 6:29 PM

Finally i had change my code like below

  Articles.As<RoutePart>().Path = Articles.As<RoutePart>().Slug;

Now my path issue is working