I recently came across a problem with importing Document Types (well, “Content Types”) using the PackagingService API. What I’ve found is that if I import a single DocType that has structure (allowed children) those children aren’t imported.
Looking into the code you’ll find this – https://github.com/umbraco/Umbraco-CMS/blob/72d4457a248529c724825ea16d86e7e2dccfe400/src/Umbraco.Core/Services/PackagingService.cs#L413-L430
In my code I am passing in the `importStructure` flag as true, but still they don’t import. Digging a bit further into the `UpdateContentTypesStructure` method what I found is this:
I got to wondering where the value of `_importedContentTypes` comes from and I found it back in the first method:
What seems to be the problem is that when you import a DocType the structure it understands can only come from the other DocTypes that were imported at that same time. Basically you can’t import a DocType and have an allowed child of a DocType that is already in your CMS.
Now, I think I understand the rationale behind this, that a Package should be entirely self-contained so you can’t depend on something that might not exist, but at the same time I’m often using a bunch of small packages as building blocks to create a site.
I’m happy to work on a PR for this, but I wanted to first ask about it before I invest time on something that is by-design and I’m essentially using the import engine “wrong”.
Just having a look into uSync and how it handles it - https://github.com/KevinJump/jumps.umbraco.usync/blob/ffed68ebd7e66f576cf34a0fb7da042d13b65440/jumps.umbraco.usync/SyncDocType.cs#L240-L277
Seems like they do a 2nd pass to fix the structure, which is what I was thinking to do.
--
You received this message because you are subscribed to the Google Groups "Umbraco development" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
umbraco-dev...@googlegroups.com.
To post to this group, send email to
umbra...@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msgid/umbraco-dev/SIXPR01MB0541F428177ACF3188472A55EE680%40SIXPR01MB0541.apcprd01.prod.exchangelabs.com.
For more options, visit https://groups.google.com/d/optout.