mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-22 20:13:50 +08:00
Adding a utility method to ImportContentContext.
--HG-- branch : dev
This commit is contained in:
@@ -59,9 +59,9 @@ namespace Orchard.Core.Common.Drivers {
|
||||
}
|
||||
|
||||
protected override void Importing(BodyPart part, ContentManagement.Handlers.ImportContentContext context) {
|
||||
var element = context.Element(part.PartDefinition.Name);
|
||||
if (element != null) {
|
||||
part.Text = element.Attribute("Text").Value;
|
||||
var importedText = context.Attribute(part.PartDefinition.Name, "Text");
|
||||
if (importedText != null) {
|
||||
part.Text = importedText;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -37,9 +37,9 @@ namespace Orchard.Core.Common.Drivers {
|
||||
}
|
||||
|
||||
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;
|
||||
var importedText = context.Attribute(field.FieldDefinition.Name + "." + field.Name, "Text");
|
||||
if (importedText != null) {
|
||||
field.Value = importedText;
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -9,8 +9,16 @@ namespace Orchard.ContentManagement.Handlers {
|
||||
Data = data;
|
||||
}
|
||||
|
||||
public XElement Element(string elementName) {
|
||||
return Data.Element(elementName);
|
||||
public string Attribute(string elementName, string attributeName) {
|
||||
var element = Data.Element(elementName);
|
||||
if (element != null) {
|
||||
var attribute = element.Attribute(attributeName);
|
||||
if (attribute != null)
|
||||
return attribute.Value;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user