Skip to content
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

Content shape alternate targeting a specific item with ContentItemId (#15572) #16679

Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/OrchardCore.Modules/OrchardCore.Contents/Shapes.cs
Original file line number Diff line number Diff line change
@@ -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);
}
46 changes: 46 additions & 0 deletions src/docs/reference/modules/Templates/README.md
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Original file line number Diff line number Diff line change
@@ -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.
dmourtzoukos marked this conversation as resolved.
Show resolved Hide resolved
dmourtzoukos marked this conversation as resolved.
Show resolved Hide resolved

#### 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.
dmourtzoukos marked this conversation as resolved.
Show resolved Hide resolved

#### Content with specific Display Type and Id Examples

| Template | Filename|
| --------- | ------------ |
| `Content_Summary__12` | `Content-12.Summary.cshtml`

## Widget templates

### `Widget__[ContentType]`