I have checked [uipath]/shell/Stores/uidescriptor and found out that dndTypes are strange for optimizingblock.
For other types which has no problems with dran&drop "dndTypes" are equal to "typeIdentifier"...
[
{
"typeIdentifier":"episerver.cms.addons.blocks.optimizingblock",
"baseTypeIdentifier":"episerver.core.blockdata",
"iconClass":"epi-iconObjectOptimizingBlock",
"dndTypes":["epi.cms.block.lighturi","epi.cms.content.lighturi"],
"languageKey":"optimizingblock",
},
Can anybody help me understand the problem?
Why Optimizingblock has such strange dndTypes?
How to change dndTypes?
Hi,
This is now fixed with the latest release of self optimizing block. You can update it from the add-ons menu.
Hi!
Here is some code for a custom attribute that extends the normal AllowedTypes attribute to accept optimizing blocks. Note that this does not actually prevent adding an optimizing block with content that is now allowed according to the allowed types attribute:
using System; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; using EPiServer.Shell.ObjectEditing; namespace Samples { /// <summary> /// Assigns types that the property accepts adding. /// </summary> [AttributeUsage(AttributeTargets.Property, AllowMultiple = false)] public sealed class CustomAllowedTypesAttribute : Attribute, IMetadataAware { private Type[] _allowedTypes; /// <summary> /// Initializes a new instance of the <see cref="AllowedTypesAttribute"/> class. /// </summary> public CustomAllowedTypesAttribute() : this(new Type[0]) { } /// <summary> /// Initializes a new instance of the <see cref="AllowedTypesAttribute" /> class. /// </summary> /// <param name="allowedTypes">The allowed types.</param> public CustomAllowedTypesAttribute(params Type[] allowedTypes) { _allowedTypes = allowedTypes; } /// <summary> /// Gets the allowed types. /// </summary> /// <value> /// The allowed types. /// </value> [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "Attributes can not contain properties that contain collections")] public Type[] AllowedTypes { get { return (Type[])_allowedTypes.Clone(); } } /// <summary> /// Gets or sets the allowed types format suffix. /// </summary> /// <value> /// The allowed types format suffix. /// </value> public string AllowedTypesFormatSuffix { get; set; } /// <summary> /// Adds the allowed types to the metadata. /// </summary> /// <param name="metadata">The model metadata.</param> public void OnMetadataCreated(ModelMetadata metadata) { var extendedMetadata = metadata as ExtendedMetadata; if (extendedMetadata != null) { List<string> allowedTypesWithFormat = _allowedTypes.Select(a => a.FullName.ToLowerInvariant()).ToList(); AddOptimizingBlock(allowedTypesWithFormat); extendedMetadata.EditorConfiguration["AllowedTypes"] = allowedTypesWithFormat.ToArray(); if (!String.IsNullOrEmpty(AllowedTypesFormatSuffix)) { allowedTypesWithFormat = allowedTypesWithFormat.Select(a => a + "." + AllowedTypesFormatSuffix).ToList(); } extendedMetadata.EditorConfiguration["AllowedDndTypes"] = allowedTypesWithFormat; extendedMetadata.OverlayConfiguration["AllowedDndTypes"] = allowedTypesWithFormat; } } private static void AddOptimizingBlock(List<string> allowedTypesWithFormat) { allowedTypesWithFormat.Add("episerver.cms.addons.blocks.optimizingblock"); } } }
This site can’t be reached
The webpage at https://koala.mazda.com.au/koala-cms/CMS/Content/contentassets/d5c62d86536745ed93c6529019bba7fb,,91291might be temporarily down or it may have moved permanently to a new web address.
Hi All,
In our project we use AllowedTypes attribute with content areas.
It works well for Blocks defined in our code.
Recently client asked us to install well-known "Self-Optimizing Block" Add-On and allow this block to be added to content areas which have AllowedTypes restrictions.
We referenced EPiServer.Cms.AddOns.Blocks.dll lib and configured "AllowedTypes":
[AllowedTypes(typeof(TestBlock), typeof(OptimizingBlock))]
public virtual ContentArea TestContentArea { get; set; }
The problem is that drag&drop doesn't work for OptimizingBlocks in All-Properties edit mode. But Drag&Drop works fine for other allowed blocks.
Why it doesn't work for OptimizingBlock?