4

So the old way to add a Admin menu was to create a controller and then an adminmenu file and number the menu item like below.

public void GetNavigation(NavigationBuilder builder) {
            var themeName = _siteThemeService.GetSiteTheme();
            if (themeName.Name == Constants.THEME_NAME) {
                builder.AddImageSet("themes")
                    .Add(T("Themes"), "10", BuildMenu);
            }
        }

        private void BuildMenu(NavigationItemBuilder menu) {
            menu.Add(T("SomeMenu"), "3", item => item.Action("Index", "Admin", new { area = Constants.ROUTES_AREA_NAME }).Permission(StandardPermissions.SiteOwner).LocalNav());

        }

But the new way with the handeler has me trying to figure out how to place the admin menu where i want. like below.

public class SomeMenuPartHandler : ContentHandler {
        public SomeMenuSettingsPartHandler() {
            T = NullLocalizer.Instance;
            Filters.Add(new ActivatingFilter<SomeMenuSettingsPart>("Site"));
            Filters.Add(new TemplateFilterForPart<SomeMenuSettingsPart>("SomeMenuSettings", "Parts/SomeMenuSettings", "Theme-Bootstrap"));
        }

        public Localizer T { get; set; }

        protected override void GetItemMetadata(GetContentItemMetadataContext context) {
            if (context.ContentItem.ContentType != "Site")
                return;
            base.GetItemMetadata(context);
            context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("SomeMenu")));
        }
    }

Would love to find the answer to this, Can anyone tell me how to use the Handler to actually place the menu item in a tab under themes.

pool pro
  • 2,084
  • 12
  • 21

0 Answers0