Virtual Happy Hour canceled for Friday May 31st.
Try our conversational search powered by Generative AI!
AI OnAI Off
Virtual Happy Hour canceled for Friday May 31st.
programmatically this is how you create a Block in content area property (page.MainContentArea)
var block = CreateBlockDataInstance("Your-block-type", migrationConfig);
((IContent)block).Name = string.IsNullOrEmpty(image.ImageTitle) ? image.Image.ImageLocalURL : image.ImageTitle;
try
{
block.Property["Title"].Value = image.ImageTitle;
block.Property["Image16x9"].Value = GetImageVaultJsonDataFromIdList("Media", new[] { image.Image.StorageImageId ?? 0 });
}
catch (Exception ex)
{
}
_contentRepository.Save((IContent)block, EPiServer.DataAccess.SaveAction.Publish);
return block;
//=====================================================
BlockData CreateBlockDataInstance(string BlockType, MigrationConfig migrationConfig)
{
IContentTypeRepository contentTypeRepository = ServiceLocator.Current.GetInstance<IContentTypeRepository>();
ContentType correctType = contentTypeRepository.Load(BlockType);
return _contentRepository.GetDefault<BlockData>(new ContentReference(migrationConfig.CMSBlockFolder), correctType.ID);
}
Hi! for all
I have a block that displays a couple of input type text. and I need to add a ContentArea
all code works, the problem is that I have to manually declare the property in / episerver / CMS / Admin / and in the tab "Content type" select "page types" -> "confirmationpage" and manually add my property AdvertisingContentArea
I understand that this should be solved with a migration but I don't know how to create it.
I don't need to migrate a block not a new model page. I need to migrate a new property.
Manual:
I don't know if I'm doing it right