Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rendering zones before rendering layout #5436
Rendering zones before rendering layout #5436
Changes from 4 commits
b2c1327
af182d4
d375fe2
6823c98
d7d2519
5ca519c
27c145c
5f3474a
82fd83d
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove useless opening / closing parenthesis =>
(Shape)ThemeLayout.Content
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, i don't think you need to remove the item here because below you will pre-render all zones (the content zone included) and then remove their items (also those of the content zone).
Notice that here the previously added
body
item is aPositionWrapper
whose metadata name and type are null, so here we remove it but only by "matching" a null name.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add
using OrchardCore.DisplayManagement.Zones
and then here just useZoneHolding
Are we sure that it is always a
ZoneHolding
, here i think so, but more globally when it is useful maybe better to useif (ThemeLayout.Content is Shape content)
,if (ThemeLayout is ZoneHolding zones)
and so on, so that you check the type and then you can use the new typed variable afterwards.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, This will always be zone holding as ThemeLayout class is for pre-compiled Layout. However you suggestion makes more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, as said above, the problem here is that an item may not have a name as the
PositionWrapper
, or e.g in the blog theme in the footer zone there is also aWidgetWrapper
whose type isWidget_Wrapper
but that has a null name. But as said above it may work but only by "matching" null names.Just tried it works even we don't remove any item and moreover without doing below
zone.Add(htmlZone)
. I think because inDefaultHtmlDisplay
there is this checkAnd when we pre-render a zone the
ChildContent
is already populated and then it is not processed again, but the other handlers are executed again, even if we still remove the items that anyway will not be rendered.Hmm, the solution would be to replace the zone completely with the related pre-rendered
IHtmlContent
this because when there is no related shape we doCoerceHtmlString()
that just return the object as is if it is anIHtmlContent
, so the handlers would not be executed again.Hmm, but when rendering a section with
required: true
we check that if the zone is not null we assume that it is a shape and then we check that it has at least one item, so it would fail here because it would not be a shape. Hmm, maybe also check that it is anIHtmlContent
or just check that zone is not null.One drawback i see with both solution if if someone would want in the layout template to deal with the items of a given zone based on some logic, but i think it would be a rare use case.
I will check the code and maybe suggest something.