November Happy Hour will be moved to Thursday December 5th.
AI OnAI Off
November Happy Hour will be moved to Thursday December 5th.
Hi Johan,
Maybe you could try to prepare generic extension methods responsible for copying one content another. The code could look like this (I didn't tested it - it's just a draft):
public static class BlockExtensions { public static T Copy<T>(this IContentRepository contentRepository, IContent sourceContent) where T : IContentData { var targetContent = contentRepository.GetDefault<T>(sourceContent.ParentLink); Copy(sourceContent, targetContent); return targetContent; } public static void Copy(IContent sourceContent, IContentData targetContent) { Validator.ValidateNotReadOnly((IReadOnly) targetContent); foreach (var targetProperty in targetContent.Property) { var type = MetaDataProperties.GetInterfaceForPageDataMetaDataProperty(targetProperty.Name); if (type == null || type == typeof (ILegacyResourceable)) { var sourceProp = sourceContent.Property[targetProperty.Name]; if (sourceProp != null) { targetProperty.Value = sourceProp.Value; } } } } }
The method will copy all properties except version specific values (like id, guid, language, etc.)
Hi
Cant you use one block as master of all content and them user partials to present them differently, with this approach its easier to structure your content an minimize the amount of blocks?
/Pär
Pär, by partials you mean to use tagging instructing EPiServer to pick anoter template in different cases?
Hi All
Might be a newbie question.
We have a case that there will be many blocks that is similar.
Eg. block 1 is a subset of block 2.
I wonder if anyone have tried to copy content from one block to another?