mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-22 20:13:50 +08:00
Adding back a DisplayType shape display alternate for the "Content" shape.
Also tweaked the order of alternates to minimize the need for additional templates when any non-DisplayType contained alternate is used. In other words. If there is a Content-BlogPost.Summary template and a Content-42 template is used to override the detail display of a blog post with an id of 42 - then a Content-42.Summary is not necessary. --HG-- branch : dev
This commit is contained in:
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.ContentManagement;
|
||||
using Orchard.DisplayManagement.Descriptors;
|
||||
|
||||
namespace Orchard.Core.Contents {
|
||||
@@ -15,15 +12,21 @@ namespace Orchard.Core.Contents {
|
||||
.OnDisplaying(displaying => {
|
||||
ContentItem contentItem = displaying.Shape.ContentItem;
|
||||
if (contentItem != null) {
|
||||
// Alternates in order of specificity.
|
||||
// Display type > content type > specific content > display type for a content type > display type for specific content
|
||||
|
||||
// Content__[DisplayType] e.g. Content.Summary
|
||||
displaying.ShapeMetadata.Alternates.Add("Content_" + displaying.ShapeMetadata.DisplayType);
|
||||
|
||||
// Content__[ContentType] e.g. Content-BlogPost
|
||||
displaying.ShapeMetadata.Alternates.Add("Content__" + contentItem.ContentType);
|
||||
|
||||
// Content_[DisplayType]__[ContentType] e.g. Content-BlogPost.Summary
|
||||
displaying.ShapeMetadata.Alternates.Add("Content_" + displaying.ShapeMetadata.DisplayType + "__" + contentItem.ContentType);
|
||||
|
||||
// Content__[Id] e.g. Content-42
|
||||
displaying.ShapeMetadata.Alternates.Add("Content__" + contentItem.Id);
|
||||
|
||||
// Content_[DisplayType]__[ContentType] e.g. Content-BlogPost.Summary
|
||||
displaying.ShapeMetadata.Alternates.Add("Content_" + displaying.ShapeMetadata.DisplayType + "__" + contentItem.ContentType);
|
||||
|
||||
// Content_[DisplayType]__[Id] e.g. Content-42.Summary
|
||||
displaying.ShapeMetadata.Alternates.Add("Content_" + displaying.ShapeMetadata.DisplayType + "__" + contentItem.Id);
|
||||
|
||||
|
Reference in New Issue
Block a user