mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-23 04:36:51 +08:00
Import handler for text fields.
--HG-- branch : dev
This commit is contained in:
@@ -36,6 +36,13 @@ namespace Orchard.Core.Common.Drivers {
|
||||
return Editor(part, field, shapeHelper);
|
||||
}
|
||||
|
||||
protected override void Importing(ContentPart part, TextField field, ImportContentContext context) {
|
||||
var element = context.Element(field.FieldDefinition.Name + "." + field.Name);
|
||||
if (element != null) {
|
||||
field.Value = element.Attribute("Text").Value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void Exporting(ContentPart part, TextField field, ExportContentContext context) {
|
||||
context.Element(field.FieldDefinition.Name + "." + field.Name).SetAttributeValue("Text", field.Value);
|
||||
}
|
||||
|
@@ -2,12 +2,15 @@ using System.Xml.Linq;
|
||||
|
||||
namespace Orchard.ContentManagement.Handlers {
|
||||
public class ImportContentContext : ContentContextBase {
|
||||
|
||||
public XElement Data { get; set; }
|
||||
|
||||
public ImportContentContext(ContentItem contentItem, XElement data)
|
||||
: base(contentItem) {
|
||||
Data = data;
|
||||
}
|
||||
|
||||
public XElement Element(string elementName) {
|
||||
return Data.Element(elementName);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user