OrchardCMS / OrchardCore

Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
https://orchardcore.net
BSD 3-Clause "New" or "Revised" License
7.45k stars 2.41k forks source link

await DisplayAsync(Model.Content.AbstractContent) render nothing in summary view #17005

Closed effapp closed 1 week ago

effapp commented 1 week ago

In details view Content-Article.cshtml, "@await DisplayAsync(Model.Content.AbstractContent)" can render correctly but in summary view Content-Article.Summary.cshtml "@await DisplayAsync(Model.Content.AbstractContent)" render nothing.

Note: Model.Content.AbstractContent is FlowPart

effapp commented 1 week ago

Model.Content.AbstractContent is null in Summary View but is not null in details view like Content-Article.cshtml

sebastienros commented 1 week ago

How I would understand that happens is:

DisplayAsync(Model.Content.AbstractContent) means the shape named AbstractContent in the zone named Content of the current Model which is a zone holder shape.

So it looks like this shape is not created for the Summary display mode.

can you describe what your Article content type is made of, and how you create the summary shapes of your articles, or where you are trying to "see" them if the view already exists? (the admin uses SummaryAdmin for instance).

ns8482e commented 1 week ago

Place it using placement for Summary view

sebastienros commented 1 week ago

@ns8482e I almost believe you like placement ;)

effapp commented 1 week ago

Hi @sebastienros ,

I think that since "DisplayAsync(Model.Content.AbstractContent)" can be displayed in details view , it should be displayed in summary view.

note: I use oc 1.8.4

effapp commented 1 week ago

Hi @sebastienros ,

Article type: image

Content-Article.cshtml image

Content-Article.Summary.cshtml image

ns8482e commented 1 week ago

@ns8482e I almost believe you like placement ;)

Creation of AbstractContent within Content depends DisplayDriver of Content part that creates it. Here the part in question is FlowPart which is not placed in Summary view only placed when it's Detail view.

So if there is need to render flow part detail into summary view then, it requires placement definition explicitly.

sebastienros commented 1 week ago

@ns8482e I realized that after your comment actually. And I think that's totally ok in term of design, a summary should not display everything like in Details.

But it's also ok because there is a way to change that: Placement!!!

Let's try to get the correct placement syntax then:

{
  "FlowPart": [
    {
      "place": "Content",
      // "differentiator": "AbstractContent",
      "contentType": "Article",
      "displayType": "Summary"
    }
  ]
}

If not this, it should be close.

Now reflecting on it, I think we should have the list of all available shape types for each part/field (we probably have it for fields, I can vaguely remember creating this list once). And explain in placement how to use this list based on the custom part names, how to build the differentiator ... (which I also feel like I documented at some point).

sebastienros commented 1 week ago

Also worth mentioning that the FlowPart_Empty shape is used when the part has no elements. https://docs.orchardcore.net/en/latest/reference/modules/Flow/#empty-flows-and-bags