From 95e558c7b5d0a545f0c6713da37ee014ff889104 Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Tue, 3 Dec 2024 14:40:41 -0800 Subject: [PATCH] specify LayerMetadata as prefix. --- .../Drivers/LayerMetadataWelder.cs | 17 ++++++++++++++--- .../TheBlogTheme/Recipes/blog.recipe.json | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Layers/Drivers/LayerMetadataWelder.cs b/src/OrchardCore.Modules/OrchardCore.Layers/Drivers/LayerMetadataWelder.cs index 416e73e6834..5a461d8124a 100644 --- a/src/OrchardCore.Modules/OrchardCore.Layers/Drivers/LayerMetadataWelder.cs +++ b/src/OrchardCore.Modules/OrchardCore.Layers/Drivers/LayerMetadataWelder.cs @@ -30,11 +30,14 @@ public override async Task EditAsync(ContentItem model, BuildEdi if (!model.TryGet(out var layerMetadata)) { layerMetadata = new LayerMetadata(); + + // In the initial request, the 'Zone' and 'Position' are passed as route values. + // We attempt to populate the new 'LayerMetadata' and ensure the 'Zone' is correctly set. await context.Updater.TryUpdateModelAsync(layerMetadata, string.Empty, m => m.Zone, m => m.Position); - // Are we loading an editor that requires layer metadata? if (string.IsNullOrEmpty(layerMetadata.Zone)) { + // At this point, the 'Zone' value was not provided in the route values, so the widget is not visible. return null; } @@ -50,8 +53,16 @@ public override async Task EditAsync(ContentItem model, BuildEdi m.Layer = layerMetadata.Layer; m.Layers = (await _layerService.GetLayersAsync()).Layers .Select(x => new SelectListItem(x.Name, x.Name)); - }) - .Location("Content:before"); + }).Location("Content:before"); + } + + protected override void BuildPrefix(ContentItem model, string htmlFieldPrefix) + { + base.BuildPrefix(model, htmlFieldPrefix); + if (string.IsNullOrWhiteSpace(htmlFieldPrefix)) + { + Prefix = nameof(LayerMetadata); + } } public override async Task UpdateAsync(ContentItem model, UpdateEditorContext context) diff --git a/src/OrchardCore.Themes/TheBlogTheme/Recipes/blog.recipe.json b/src/OrchardCore.Themes/TheBlogTheme/Recipes/blog.recipe.json index bce48abc1cf..ceabdaee507 100644 --- a/src/OrchardCore.Themes/TheBlogTheme/Recipes/blog.recipe.json +++ b/src/OrchardCore.Themes/TheBlogTheme/Recipes/blog.recipe.json @@ -1100,7 +1100,7 @@ { "ContentItemId": "[js: uuid()]", "ContentType": "RawHtml", - "Displaytext": "Footer", + "DisplayText": "Footer", "Latest": true, "Published": true, "Owner": "[js: parameters('AdminUserId')]",