Decorate propertis with property settings?

Member since: 2007

Hi,


Is it possible to decorate propertis with property settings?


I have property settings for a custom property and would like to specify those settings on my properties, it's quite cumbersome to go into admin mode and set those settings.

#71889 May 31, 2013 11:06
  • Member since: 2008

    Last time I checked there wasn't a built in configuration builder similar to what you could find in PageTypeBuilder.

    If you have an existing PropertySetting or creating one at startup I guess you can use an EditorDescriptor to set your configuration.

    Checkout EPiServer.Cms.Shell.UI.ObjectEditing.EditorDescriptors.XhtmlStringEditorDescriptor in the EPiServer.Cms.Shell.UI (usually found in the Modules-path among your VPP) for some inspiration.

        public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
        {
          base.ModifyMetadata(metadata, attributes);
          TinyMCESettings settings = (TinyMCESettings) ((PropertyData) metadata.Model).GetSetting(typeof (TinyMCESettings));
          ExtendedMetadata mostContentMetadata = ExtendedMetadataExtensions.FindTopMostContentMetadata(metadata);
          IContent content = mostContentMetadata != null ? mostContentMetadata.Model as IContent : (IContent) null;
          TinyMCEInitOptions tinyMceInitOptions = new TinyMCEInitOptions(TinyMCEInitOptions.InitType.EditMode, settings, content);
          if (metadata.IsReadOnly)
          {
            tinyMceInitOptions.InitOptions["readonly"] = (object) true;
            tinyMceInitOptions.InitOptions["body_class"] = (object) "mceReadOnly";
          }
          metadata.EditorConfiguration.Add("width", tinyMceInitOptions.InitOptions["width"]);
          metadata.EditorConfiguration.Add("height", tinyMceInitOptions.InitOptions["height"]);
          metadata.EditorConfiguration.Add("settings", (object) tinyMceInitOptions.InitOptions);
        }

        

    #71975 Edited, Jun 03, 2013 14:21