I'm prototyping an orchardproject.net cms. I've created a content type of "product." I've create a list called "Cheap products list" and a list call "Fun products list." This works great until I have a product that needs to be in both fun and cheap lists.
I've gotten this far without any custom code. I suspect that this feature requires some code. But I'm a little amazed that someone hasn't written a generic version of this as a module. I'm tempted to write it myself but the fact that no one else has done it give me pause. Is there a constraint that makes this feature exceedingly difficult?
Should I write a specific implementation using the one to many sample on the orchard site before I try to write a generic one?
Any guidance would b开发者_如何学JAVAe appreciated! Dan
You should consider using Taxonomies instead of lists in that scenario. Cheap and fun should be taxonomy terms, not containers. No code required.
Orchard, by default, allows a single content item to be assigned to single list, but you are free to create your own implementation. It's not that difficult to implement as it may seem. The fact that such feature is not there is because the Team focused on more important things (like performance) lately.
Take a look at Orchard.Core.Containers and Orchard.Lists to see how they are implemented. You could, for example, create your own part that would allow attaching an arbitrary item to different lists and create a controller that would build the final shape.
Check the Orchard.Core.Containers.Controllers.ItemController - there the whole magic happens. Id of a corresponding container (which you choose from the select list "Add to:") is held inside CommonPart.Container.Id property so you can follow this pattern and create a part that would hold a collection of Ids, attach that to content types you want and do the rendering exactly like in that ItemController.
精彩评论