/// <summary>
 /// Method is used to ensure that menu values that will be used for navigation are properply populated
 /// </summary>
 /// <param name="wpMenuModel"></param>
 private static void EnsureMenuSlugValue(WPMenuModel wpMenuModel)
 {
     //loop through each menu item and apply
     if (wpMenuModel != null && wpMenuModel.items != null && wpMenuModel.items.Any())
     {
         foreach (var wpItem in wpMenuModel.items)
         {
             EnsureMenuSlugValue(wpItem);
         }
     }
 }
        private static WPMenuModel MapWPMenu(dynamic jsonObj)
        {
            var wpMenuModel = new WPMenuModel();

            //for a single MENU content request
            wpMenuModel = JsonConvert.DeserializeObject(jsonObj, typeof(WPMenuModel));

            EnsureMenuSlugValue(wpMenuModel);

            WPMenuBuilder.AddMenuStyle(wpMenuModel);

            return(wpMenuModel);
        }
Beispiel #3
0
 /// <summary>
 /// Build the UI decorations for the WordPress Menu
 /// </summary>
 /// <param name="wpMenuItemCollection"></param>
 private static void AddWPMenuStyle(WPMenuModel wpMenuItemCollection)
 {
     //menu decoration for the overall menu level
     if (wpMenuItemCollection != null && wpMenuItemCollection.items != null && wpMenuItemCollection.items.Any())
     {
         wpMenuItemCollection.styles = new Dictionary <string, string>();
         wpMenuItemCollection.styles.Add("divTopMenuClass", "class=main-menu");
         wpMenuItemCollection.styles.Add("ulTopMenuId", "id =menu-dropdown-menu-1-0");
         wpMenuItemCollection.styles.Add("ulTopMenuClass", "class=menu");
         foreach (var wpContentItem in wpMenuItemCollection.items)
         {
             //menu decoration for the top level menu items
             AddWPMenuStyle(wpContentItem);
         }
     }
 }
Beispiel #4
0
 /// <summary>
 /// Build the UI decorations for the WordPress Menu
 /// </summary>
 /// <param name="wpMenuItemCollection"></param>
 private static void AddMVCMenuStyle(WPMenuModel wpMenuItemCollection)
 {
     //menu decoration for the overall menu level
     if (wpMenuItemCollection != null && wpMenuItemCollection.items != null && wpMenuItemCollection.items.Any())
     {
         wpMenuItemCollection.styles = new Dictionary <string, string>();
         wpMenuItemCollection.styles.Add("divTopMenuClass", "class='navbar-collapse collapse'");
         wpMenuItemCollection.styles.Add("ulTopMenuId", null);
         wpMenuItemCollection.styles.Add("ulTopMenuClass", "class='nav navbar-nav'");
         foreach (var wpContentItem in wpMenuItemCollection.items)
         {
             //menu decoration for the top level menu items
             AddMVCMenuStyle(wpContentItem);
         }
     }
 }
        /// <summary>
        /// Method is used when other controllers want to inherit from WPController and use the Menu capabilities
        /// </summary>
        /// <param name="menuOption"></param>
        /// <returns></returns>
        public WPMenuModel Menu(MenuOptions menuOption)
        {
            var contentModel = new WPMenuModel();

            switch (menuOption)
            {
            case MenuOptions.TOPNAV:
                contentModel = GetMenuContentCollection(TopNavMenuId);
                break;

            case MenuOptions.FOOTNAV:
                contentModel = GetMenuContentCollection(FootNavMenuId);
                break;

            default:
                contentModel = GetMenuContentCollection(TopNavMenuId);
                break;
            }

            return(contentModel);
        }
Beispiel #6
0
        public static void AddMenuStyle(WPMenuModel wpMenuItemCollection)
        {
            var menuBuilderSettings = ConfigurationManager.AppSettings["UseMenuBuilder"];
            var useMenuBuilder      = !string.IsNullOrEmpty(menuBuilderSettings) ? Convert.ToBoolean(menuBuilderSettings) : false;

            if (useMenuBuilder)
            {
                var MVCMenuDecoration = ConfigurationManager.AppSettings["UseMVCMenuDecoration"];
                var useMVCDecoration  = !string.IsNullOrEmpty(MVCMenuDecoration)
                    ? Convert.ToBoolean(MVCMenuDecoration)
                    : false;

                switch (useMVCDecoration)
                {
                case true:
                    AddMVCMenuStyle(wpMenuItemCollection);
                    break;

                default:
                    AddWPMenuStyle(wpMenuItemCollection);
                    break;
                }
            }
        }