Our solution is to add an interface to the block:
public class SliderBlock : INotAvailableContent {}
The interface and descriptor:
public interface INotAvailableContent { } [UIDescriptorRegistration] public class NotAvailableContentDescriptor : UIDescriptor<INotAvailableContent> { }
The ContentArea defintion:
[AllowedTypes(RestrictedTypes = new[] { typeof(INotAvailableContent) })] public virtual ContentArea MainContentArea { get; set; }
Now you can easy add INotAvailableContent for ContentAreas and blocks to avoid them.
Thanks Empa.
I am presuming I would still need to tag all my content area fields with the attribute
[AllowedTypes(RestrictedTypes = new[] { typeof(INotAvailableContent) })]
It is certainly less work than excluding each block individualy but would have been nice to have something which we could add onto the SliderBlockItem class to just exlude it from all content area apart from the one we exclusively specify.
Kind regards
Sandeep
Thank you very much. As mentioned still less work than adding each one manually.
Just to implement something when starting the project so that it is not a lot of work later.
Kind regards
Sandeep
It seems like doing
[ContentType(AvailableInEditMode = false, GUID = "D8D1795B-1990-498E-A6A7-C5DF238E150A")]
on your block type does the trick? Is that not a simpler way to do it?
Hi
I have a SliderContainerBlock and an SliderItemBlock.
I am able to restirct the items which can be added into the SliderContainerBlock by using the following
[AllowedTypes(typeof(SliderItemBlock))]
public virtual ContentArea SliderItemBlocksContentArea { get; set; }
which works fine.
However I also want that the SliderItemBlock cannot be added to any other content area on the site.
[SiteContentType(GUID = "117a95a1-86ed-4dd7-b70d-a2736482734d",
GroupName = Global)]
[AvailableContentTypes(Availability.Specific, Include = new[] { typeof(SliderContainerBlock)}]
public class SliderItemBlock : SiteBlockData
using the following attribute does not seem to work.
[AvailableContentTypes(Availability.Specific, Include = new[] { typeof(SliderContainerBlock)}]
Is it possible to restirct a block in all content areas and only allow them in the ones I want. I do not want to go to every content area on the site and specifcy the allowed types.
Kind regards
Sandeep