Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
There's not really a way to copy the values from one page to another page out of the box.
How many properties do you have, I'd suggest either writing a job if not many or just writing a SQL script to copy the values which shouldn't be too hard
That I know. Which is why I experimented with the above code in a scheduled job (executed once).
There are quite a lot of properties, content areas, custom properties etc.
IContentCopyHandler would be nice if you could specifiy which properties :)
I don't really want to do a loop and custom checks for each type - but it doesn't sound like I have a choise.
I found a way to do it for those whom are interested.
Inject IContentTypeRepository and...
var contentType = _contentTypeRepository.Load(sourcePage.ContentTypeID);
foreach (var definition in contentType.PropertyDefinitions)
{
var propertyValue =
sourcePage.GetPropertyValue<object?>(definition.Name);
if (propertyValue is XhtmlString xhtmlString)
{
targetPage.SetPropertyValue(definition.Name,
new XhtmlString(xhtmlString.ToInternalString()));
}
else
{
targetPage.SetPropertyValue(definition.Name,
propertyValue);
}
}
There are some special handling. E.g 'XhtmlString' and 'ContentArea' but it's doable this way.
How do I copy only specified properties to another page?
E.g. we have a SettingPage which we want to copy declared properties to the StartPage (then delete the SettingPage).
I found there was a property exporter, but it doesn't seem to do what I thought it was.
Any ideas?