Deep Level Lists

Topics: Core, Customizing Orchard
Oct 5, 2012 at 10:28 AM

I created a advanced List contenttype.
Basicly its a list that is also containable.

So my setup is i have a
List of my advanced list which contain items.

But when orchard renders this, it only creates a list of titles from my advanced lists.
It does not render my items whithin my advanced list.

I presume there's some recursion missing somwhere to make this work, but i wouldn't have a clue as to where start looking. Any assistance would be gratefull.

Developer
Oct 6, 2012 at 10:15 AM

By "list" you mean a content type having ProjectionPart or ContainerPart? Either way, that happens because when content items are listed mostly they're displayed with the Summary display type. And when in this mode they won't show contained items. More specifically ProjectionPart won't display items when in being shown from a projection to prevent infinite recursion.

Oct 8, 2012 at 7:51 AM

By "list" you mean a content type having ProjectionPart or ContainerPart?

Yes. But i would need recursion on lists.
I didn't think about infinite recursion being a reason, but i would need a solution for this. In worst case could an exisiting contenttype made in Orchard be overwritten through a module be writing a custom Display method? One that would load the items from the second level lists?

Developer
Oct 8, 2012 at 10:46 AM

Yes on which one? :-) ProjectionPart won't work as I've said, by design. I don't know about ContainerPart, that probably would because it's not as dynamic as projections.

In the worst case you could create your won driver for ProjectionPart (there can be multiple drivers for the same part), fetch and display a query from there if you're absolutely sure there will no recursion occur.

Oct 8, 2012 at 10:49 AM

its not a projection, it's a Containerpart.

I'm looking into writting my own driver now.
I'm still not complete sure how to write a driver for an existing part like ContainerPart.

Oct 8, 2012 at 1:18 PM

I've tried this in my driver

if (!part.ItemContentType.ToString().Equals("AdvListItem"))
                return null;

            IEnumerable items = part.ContentItem.ContentManager.Query("AdvListItem").ForVersion(VersionOptions.Latest).Where(c => c.Container.Id == part.ContentItem.Id).List();
           
            //
            var list = shapeHelper.List();
            list.AddRange(items.Select(p => part.ContentItem.ContentManager.BuildDisplay(p, "Detail")));
            return ContentShape("Parts_Container_Contained", () => shapeHelper.Parts_Container_Contained(
                List : list
                ));
This does seem to load my items, but it still returns my advList as a summary instead of a List of AdvListItems

Developer
Oct 8, 2012 at 7:30 PM

So the items being in the list are displayed like when in summary, despite being built for detail? Then I have no idea, it should work.

Oct 9, 2012 at 7:36 AM

Indeed, that's what i'm saying.

Anyway not really knowing what projections where for, i've been able to help myself by creating a projection for each adv list instead. And combining the projections onto 1 page using widgets. So thanks for the help.

Not really what i wanted but it'll suffice.