Field template alternates based on field name and content part/type name

When a ContentShape is returned from a ContentFieldDriver alternates are added automatically
Patterns include:
ShapeName
ShapeName__FieldName
ShapeName__PartName
ShapeName__FieldName__PartName

For content fields the part name is, essentially, always the same as the content type name
Field drivers must add a ContentPart property to the shape they return, or only the field name will be a valid alternate
Updated TextFieldDriver
Fixed a bug where a dash after a dot in a file name was preventing proper harvesting

--HG--
branch : dev
extra : rebase_source : cae3d8cf544628b5f35cfc584ebbedf4d505c8ce
This commit is contained in:
Louis DeJardin
2010-12-10 16:24:03 -08:00
parent c93f4d9985
commit 58b29c79ad
6 changed files with 58 additions and 11 deletions

View File

@@ -22,7 +22,7 @@ namespace Orchard.Core.Common.Drivers {
protected override DriverResult Display(ContentPart part, TextField field, string displayType, dynamic shapeHelper) {
return ContentShape("Fields_Common_Text", GetDifferentiator(field, part),
() => shapeHelper.Fields_Common_Text(ContentField: field, Name: field.Name, Value: field.Value));
() => shapeHelper.Fields_Common_Text(ContentPart: part, ContentField: field, Name: field.Name, Value: field.Value));
}
protected override DriverResult Editor(ContentPart part, TextField field, dynamic shapeHelper) {

View File

@@ -20,11 +20,6 @@ namespace Orchard.Core.Common {
string flavor = displaying.Shape.EditorFlavor;
displaying.ShapeMetadata.Alternates.Add("Body_Editor__" + flavor);
});
builder.Describe("Fields_Common_Text")
.OnDisplaying(displaying => {
string textFieldName = displaying.Shape.Name;
displaying.ShapeMetadata.Alternates.Add("Fields_Common_Text__" + textFieldName);
});
}
[Shape]