1

I created a custom Type that has a UserPart attached to it.

According to this issue on GitHub you can't add a CommonPart to content that also has a UserPart because it causes a StackOverflowException but I would still like items of my custom Type to show up in the content list. I already store CreatedUtc and PublishedUtc in the custom PartRecord, can I manually plug these in somewhere?

EDIT: For clarification, my specific scenario is that I am building a public facing Orchard website based on existing data that was used in a private application up to this point. I have a legacy table with user accounts that need to be mapped to Orchard Users but they also represent travel agencies that visitors should be able to browse and that Orchard admins should easily be able to edit and create through the Dashboard. I got the idea to create a TravelAgency type with a UserPart from Sipke's webshop tutorial

4

1 回答 1

1

内容类型不需要在内容列表中显示 CommonPart。如果我没记错的话,它是通过在您的迁移中触发 Createable() 来完成的。此外,如果您有一个 UserPart,您可以延迟加载或仅通过外键引用它。

为什么您希望这样的内容成为内容列表的一部分?我通常将特定于业务的内容类型隐藏在一个不错的部分中,以便用户更容易可视化和使用。

肯定有一个错误,但正如他们评论的那样,您可以扩展分类法来完成您的任务,并记住有时更改 Orchard 代码库可能适合您的目的,您只需在下次升级时跟踪您的更改。我已经做了几次以适应我的项目。

如果我没记错的话,已经有一段时间了。如果您查看创建内容列表的核心代码,它会查找 Creatable() 类型。在代码中挖掘更多,负责的查询很可能会加入 CommonPart,因此你的问题。您可以轻松地在控制器中添加另一个查询并添加您想要的任何内容。但是,问题在于重构其余的操作以适应您的类型。更容易隔离您的新类型。不得不为你看,检查这个宝贝:Orchard.Core.Contents.Controllers.AdminController

于 2016-11-01T09:54:43.373 回答