From 46c888701d395c549d23f15e6e16afd4964cdf3d Mon Sep 17 00:00:00 2001 From: "LIGHTHOUSE-HQ\\dmourtzoukos" Date: Fri, 6 Sep 2024 14:43:11 +0300 Subject: [PATCH 1/4] Add new template alternates and update documentation Introduce new template alternates in Shapes.cs for content items based on `ContentItemId`: - `Content__[ContentItemId]` - `Content_[DisplayType]__[ContentItemId]` Update README.md to document the new alternates, including: - Descriptions of when each template is called - Examples of template filenames - Notes on deprecation of `Id` based templates, recommending `ContentItemId` based templates instead --- .../OrchardCore.Contents/Shapes.cs | 6 +++ .../reference/modules/Templates/README.md | 46 +++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Shapes.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Shapes.cs index 88d84cd149a..d184b1efd68 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Shapes.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Shapes.cs @@ -32,12 +32,18 @@ public override ValueTask DiscoverAsync(ShapeTableBuilder builder) // Content__[ContentType] e.g. Content-BlogPost, displaying.Shape.Metadata.Alternates.Add("Content__" + encodedContentType); + // Content__[ContentItemId] e.g. Content-42n8364bk2azcy1yd71gnrntwf, + displaying.Shape.Metadata.Alternates.Add("Content__" + contentItem.ContentItemId); + // Content__[Id] e.g. Content-42, displaying.Shape.Metadata.Alternates.Add("Content__" + contentItem.Id); // Content_[DisplayType]__[ContentType] e.g. Content-BlogPost.Summary displaying.Shape.Metadata.Alternates.Add("Content_" + displaying.Shape.Metadata.DisplayType + "__" + encodedContentType); + // Content_[DisplayType]__[ContentItemId] e.g. Content-42n8364bk2azcy1yd71gnrntwf.Summary + displaying.Shape.Metadata.Alternates.Add("Content_" + displaying.Shape.Metadata.DisplayType + "__" + contentItem.ContentItemId); + // Content_[DisplayType]__[Id] e.g. Content-42.Summary displaying.Shape.Metadata.Alternates.Add("Content_" + displaying.Shape.Metadata.DisplayType + "__" + contentItem.Id); } diff --git a/src/docs/reference/modules/Templates/README.md b/src/docs/reference/modules/Templates/README.md index 63cd3c2a240..9746f0e1df3 100644 --- a/src/docs/reference/modules/Templates/README.md +++ b/src/docs/reference/modules/Templates/README.md @@ -51,6 +51,52 @@ For instance, when a content item is displayed in a list, the `Summary` display | `Content_Summary__BlogPost` | `Content-BlogPost.Summary.cshtml` | | `Content_Summary__Article` | `Content-Article.Summary.cshtml` | +### `Content_[ContentItemId]` + +This template is called when displaying a content item with a specific ContentItemId. + +#### Content with specific ContentItemId Examples + +| Template | Filename| +| --------- | ------------ | +| `Content__42n8364bk2azcy1yd71gnrntwf` | `Content-42n8364bk2azcy1yd71gnrntwf.cshtml` + +### `Content_[DisplayType]__[ContentItemId]` + +This template is called when displaying a content item with a specific display type and ContentItemId. +For instance, when a content item is displayed in a list, the `Summary` display type is commonly used. + +#### Content with specific Display Type and ContentItemId Examples + +| Template | Filename| +| --------- | ------------ | +| `Content_Summary__42n8364bk2azcy1yd71gnrntwf` | `Content-42n8364bk2azcy1yd71gnrntwf.Summary.cshtml` + +### `Content_[Id]` + +This template is called when displaying a content item with a specific Id. + +Note: This template was supported on Orcard Core version 1.X and will probably be removed from future versions. It is strongly recommended to use the corresponding template that utilises the ContentItemId. + +#### Content with specific Id Examples + +| Template | Filename| +| --------- | ------------ | +| `Content__12` | `Content-12.cshtml` + +### `Content_[DisplayType]__[Id]` + +This template is called when displaying a content item with a specific display type and Id. +For instance, when a content item is displayed in a list, the `Summary` display type is commonly used. + +Note: This template was supported on Orcard Core version 1.X and will probably be removed from future versions. It is strongly recommended to use the corresponding template that utilises the ContentItemId. + +#### Content with specific Display Type and Id Examples + +| Template | Filename| +| --------- | ------------ | +| `Content_Summary__12` | `Content-12.Summary.cshtml` + ## Widget templates ### `Widget__[ContentType]` From dc8e99d3b6d8045f55893771cefaf8ba6bc21a57 Mon Sep 17 00:00:00 2001 From: "LIGHTHOUSE-HQ\\dmourtzoukos" Date: Fri, 6 Sep 2024 14:45:33 +0300 Subject: [PATCH 2/4] Update template naming conventions in README.md --- src/docs/reference/modules/Templates/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/docs/reference/modules/Templates/README.md b/src/docs/reference/modules/Templates/README.md index 9746f0e1df3..9f1d3abc963 100644 --- a/src/docs/reference/modules/Templates/README.md +++ b/src/docs/reference/modules/Templates/README.md @@ -51,7 +51,7 @@ For instance, when a content item is displayed in a list, the `Summary` display | `Content_Summary__BlogPost` | `Content-BlogPost.Summary.cshtml` | | `Content_Summary__Article` | `Content-Article.Summary.cshtml` | -### `Content_[ContentItemId]` +### `Content__[ContentItemId]` This template is called when displaying a content item with a specific ContentItemId. @@ -72,7 +72,7 @@ For instance, when a content item is displayed in a list, the `Summary` display | --------- | ------------ | | `Content_Summary__42n8364bk2azcy1yd71gnrntwf` | `Content-42n8364bk2azcy1yd71gnrntwf.Summary.cshtml` -### `Content_[Id]` +### `Content__[Id]` This template is called when displaying a content item with a specific Id. From 496dcafab8eb436a7456039928df0654ed7b1af6 Mon Sep 17 00:00:00 2001 From: "LIGHTHOUSE-HQ\\dmourtzoukos" Date: Fri, 6 Sep 2024 15:59:07 +0300 Subject: [PATCH 3/4] Minor fixes on documentation --- src/docs/reference/modules/Templates/README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/docs/reference/modules/Templates/README.md b/src/docs/reference/modules/Templates/README.md index 9f1d3abc963..019ca2d14f5 100644 --- a/src/docs/reference/modules/Templates/README.md +++ b/src/docs/reference/modules/Templates/README.md @@ -76,7 +76,7 @@ For instance, when a content item is displayed in a list, the `Summary` display This template is called when displaying a content item with a specific Id. -Note: This template was supported on Orcard Core version 1.X and will probably be removed from future versions. It is strongly recommended to use the corresponding template that utilises the ContentItemId. +Note: This template was supported on Orchard version 1.X and will probably be removed from future versions. It is strongly recommended to use the corresponding template that utilizes the ContentItemId. #### Content with specific Id Examples @@ -89,8 +89,6 @@ Note: This template was supported on Orcard Core version 1.X and will probably b This template is called when displaying a content item with a specific display type and Id. For instance, when a content item is displayed in a list, the `Summary` display type is commonly used. -Note: This template was supported on Orcard Core version 1.X and will probably be removed from future versions. It is strongly recommended to use the corresponding template that utilises the ContentItemId. - #### Content with specific Display Type and Id Examples | Template | Filename| From 8b674b4fbe6df2b549670746a2437edc0bdca8bd Mon Sep 17 00:00:00 2001 From: Mike Alhayek Date: Tue, 26 Nov 2024 16:16:44 -0800 Subject: [PATCH 4/4] encode --- src/OrchardCore.Modules/OrchardCore.Contents/Shapes.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OrchardCore.Modules/OrchardCore.Contents/Shapes.cs b/src/OrchardCore.Modules/OrchardCore.Contents/Shapes.cs index d184b1efd68..bbe0dea87a6 100644 --- a/src/OrchardCore.Modules/OrchardCore.Contents/Shapes.cs +++ b/src/OrchardCore.Modules/OrchardCore.Contents/Shapes.cs @@ -33,7 +33,7 @@ public override ValueTask DiscoverAsync(ShapeTableBuilder builder) displaying.Shape.Metadata.Alternates.Add("Content__" + encodedContentType); // Content__[ContentItemId] e.g. Content-42n8364bk2azcy1yd71gnrntwf, - displaying.Shape.Metadata.Alternates.Add("Content__" + contentItem.ContentItemId); + displaying.Shape.Metadata.Alternates.Add("Content__" + contentItem.ContentItemId.EncodeAlternateElement()); // Content__[Id] e.g. Content-42, displaying.Shape.Metadata.Alternates.Add("Content__" + contentItem.Id); @@ -42,7 +42,7 @@ public override ValueTask DiscoverAsync(ShapeTableBuilder builder) displaying.Shape.Metadata.Alternates.Add("Content_" + displaying.Shape.Metadata.DisplayType + "__" + encodedContentType); // Content_[DisplayType]__[ContentItemId] e.g. Content-42n8364bk2azcy1yd71gnrntwf.Summary - displaying.Shape.Metadata.Alternates.Add("Content_" + displaying.Shape.Metadata.DisplayType + "__" + contentItem.ContentItemId); + displaying.Shape.Metadata.Alternates.Add("Content_" + displaying.Shape.Metadata.DisplayType + "__" + contentItem.ContentItemId.EncodeAlternateElement()); // Content_[DisplayType]__[Id] e.g. Content-42.Summary displaying.Shape.Metadata.Alternates.Add("Content_" + displaying.Shape.Metadata.DisplayType + "__" + contentItem.Id);