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:
Nathan Heskew
2011-02-28 06:15:59 -08:00
parent be00e42637
commit 894a3aa505

View File

@@ -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);