November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
Try the [ScaffoldColumn(false)] or the [Editable(false)] attributes instead.
Avoid using Ignore attribute on blocks or pages. "here be dragons".
Ignored properties are not really stored by Episerver in the background. They use a static class to store them so it will be wiped when IIS reset etc. Using load balancing and this can cause some serious headaches. So stay away from that one.
I don't want to use [Editable(false)]
because I want it to be hidden not just "disabled".
If I use [ScaffoldColumn(false)]
I get an error "NotSupportedException: The property IsRowLayoutItem is read-only" in RowLayoutBlockContentEventListener on rowLayoutItem.IsRowLayoutItem = true
EDIT: Fixed it with a writable clone and a bunch of ugly casts. Seems to work, thanks!
private static void SetIsRowLayoutItemOnItems(ContentEventArgs args)
{
if(args.Content is RowLayoutBlock rowLayoutBlock && rowLayoutBlock.Items?.Items != null)
{
var contentRepository = ServiceLocator.Current.GetInstance<IContentRepository>();
foreach (var item in rowLayoutBlock.Items.Items)
{
if (contentRepository.TryGet<IRowLayoutItemBlock>(item.ContentLink, out var rowLayoutItem))
{
var content = (IContent)((IReadOnly)rowLayoutItem).CreateWritableClone();
((IRowLayoutItemBlock)content).IsRowLayoutItemBlock = true;
contentRepository.Save(content, SaveAction.Publish | SaveAction.ForceCurrentVersion, AccessLevel.NoAccess);
}
}
}
}
If you want to disable the property, or show is as read-only, you could use this attribute:
[Editable(false)]
I have a Block type that allows nested blocks for structuring block layouts.
IRowLayoutItemBlock contains a flag that tells the front-end that this block should be handled a little bit differently.
I don't want this flag to be visible/editable in the CMS editor and I've added the [Ignore] attribute on the inherited member.
To set this flag I've subscribed an event handler on SavingContent and CreatingContent
This all work perfectly until I do a restart of IIS when all the flags are unset/set to false for some reason.
Is there a better way to do this or am I just missing something?