Hiding "Shortcut" option on Settings tab and filtering out Shortcut Types

Vote:
 

Greetings,

We have some specific requirements and I have been trying to figure out how to do either within EPiServer and was wondering if anyone could shed some light or offer assistance on the following 2 cases below.

  1. Is there a way to hide the "Shortcut" option in the Settings tab depending on the specific page type?

  2. Is there a way to filter out certain Shortcut types on the Shortcut option? (i.e. Hide the "Fetch content from another Content item").

Thanks

#222227
Apr 30, 2020 15:58
Vote:
 

1. This is quite easy. Just have a look at my blog post on how to hide the Category property: https://www.gulla.net/hiding-episervers-category-property/ and combine that with my blogpost on how to move the Shortcut property: https://www.gulla.net/move-property-to-non-existing-tab/ and add a check for the page type, and you are good to go!

Something like this, to hide the Shortcut property for all instances of ArticlePage.

using System;
using System.Collections.Generic;
using EPiServer.Core;
using EPiServer.Shell.ObjectEditing;
using EPiServer.Shell.ObjectEditing.EditorDescriptors;
using TinyMCE.Models.Pages;

namespace Alloy.Business.EditorDescriptors
{
    [EditorDescriptorRegistration(TargetType = typeof(ContentData))]
    public class HideShortcutEditorDescriptor : EditorDescriptor
    {
        public override void ModifyMetadata(ExtendedMetadata metadata, IEnumerable<Attribute> attributes)
        {
            if (metadata.Model is ArticlePage)
            {
                foreach (var modelMetadata in metadata.Properties)
                {
                    var property = (ExtendedMetadata) modelMetadata;
                    if (property.PropertyName == "iversionable_shortcut")
                    {
                        property.ShowForEdit = false;
                    }
                }
            }
        }
    }
}
#222229
Apr 30, 2020 19:35
Vote:
 

2. This could need some more investigation. The dojo widget used for displaying the Shortcut settings is epi-cms/contentediting/editors/ShortcutEditor. You could maybe create your own version of that?

Or maybe, even better, override the selection factory used for providing values for the dropdown. The type you are looking for is EPiServer.Cms.Shell.UI.ObjectEditing.EditorDescriptors.SelectionFactories.PageShortcutTypeSelectionFactory and it looks like this:

using EPiServer.Core;
using EPiServer.Framework.Localization;
using EPiServer.Shell.ObjectEditing;
using System;

namespace EPiServer.Cms.Shell.UI.ObjectEditing.EditorDescriptors.SelectionFactories
{
  [SelectionFactoryRegistration]
  public class PageShortcutTypeSelectionFactory : EnumSelectionFactory
  {
    public PageShortcutTypeSelectionFactory()
      : this(LocalizationService.Current)
    {
    }

    public PageShortcutTypeSelectionFactory(LocalizationService localizationService)
      : base(localizationService)
    {
    }

    protected override string GetStringForEnumValue(int value)
    {
      return this.LocalizationService.GetString("/episerver/cms/widget/shortcutblockeditor/shortcuttype" + (object) value);
    }

    protected override Type EnumType
    {
      get
      {
        return typeof (PageShortcutType);
      }
    }
  }
}
#222230
Edited, Apr 30, 2020 19:47
Vote:
 

Hey Tomas thanks for your assistance on this, it's much appreciated :)

The first option for hiding the Shortcut editor works perfectly.

Unfortunately, when I tried your second item (suggestion of overriding the selection factory in order to filter out the shortcut types) it doesn't seem to be working as expected. I am finding that when debugging, the class constructor:

PageShortcutTypeSelectionFactory(LocalizationService localizationService) : base(localizationService) { }


Is the only thing being hit in the overriden version that you gave as an example, so i'm not sure how to intercept the values returned to filter them out, unless i'm missing something here?

#222263
Edited, May 01, 2020 14:51
Vote:
 

I looked some more at option 2 myself but didn't succeed... :-(

#222303
May 02, 2020 12:35
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.