SaaS CMS has officially launched! Learn more now.

Export certain properties from page instance and importing on another page instance


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.

var contentInfo = _contentRetriever.CreateRawContentInfo(settingsPage.ContentLink, cultureInfo.Name);
var propertyList = settingsPage.GetType()
				.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly)
				.Select(x => x.Name)

var targetPropertyList = contentInfo.RawContent.Property.Where(x => propertyList.Contains(x.Name)).ToList();
var rawContent = new RawContent();

_propertyExporter.ExportProperties(settingsPage, targetPropertyList, new PropertyExportContext
				TransferOptions = new TransferExportOptions
					AutoCloseStream = true,
					ExcludeFiles = false,
					RequiredSourceAccess = AccessLevel.NoAccess,
					TransferType = TypeOfTransfer.Copying,
					IncludeReferencedContentTypes = false,
					ExportPropertySettings = false,
				Output = rawContent,
				Source = settingsPage,

Any ideas?

Edited, Jan 09, 2024 21:35

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

Jan 11, 2024 16:28

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.

Jan 11, 2024 22:12

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 =

				if (propertyValue is XhtmlString xhtmlString)
									new XhtmlString(xhtmlString.ToInternalString()));

There are some special handling. E.g 'XhtmlString' and 'ContentArea' but it's doable this way.

Jan 24, 2024 9:09
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.