+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Additional Admin menus

Additional Admin menus

7 posts, 0 answered
  1. Brian
    Brian avatar
    31 posts
    Registered:
    25 Jun 2009
    28 Oct 2010
    Link to this post
    Hi all,

    I have an issue I just can't get worked out & wanted to see if I could get some help.  In the admin you have the top nav area (Dashboard, Pages, Modules etc..).  I have been able to add a submenu item under the Administration tab before with no problem.  Now I want to add an additional top nav menu item between Administration & Live Site.  I have it kind of working with the code below.  In the Admin.Master.cs file I'm calling a custom method in Page_Load after the MainMenu.DataBind().

    01.// Remove Live Site Tab
    02.RadTab tabLiveSite = new RadTab();
    03.tabLiveSite = MainMenu.Tabs.FindTabByText("Live Site");
    04.MainMenu.Tabs.Remove(tabLiveSite);
    05.  
    06.// Add Custom Tabs
    07.RadTab tabAppConfigs = new RadTab();
    08.tabAppConfigs.Text = "App Configuration";
    09.tabAppConfigs.NavigateUrl = "My New Page";
    10.MainMenu.Tabs.Add(tabAppConfigs);
    11. 
    12.IList<RadTab> tabsCollection = MainMenu.GetAllTabs();
    13.foreach (RadTab t in tabsCollection)
    14.{
    15.  RadTab parent = MainMenu.Tabs.FindTabByText("App Configuration");
    16.  RadTab tabAppConfigsGeneral = new RadTab("AppConfig General", "appconfig_general");   
    17.  tabAppConfigsGeneral.NavigateUrl = "My New Page";
    18.  parent.Tabs.Add(tabAppConfigsGeneral);
    19.}
    20.  
    21.// Add the Live Site Tab Back
    22.// This should be the last tab in the top nav menu
    23.MainMenu.Tabs.Add(tabLiveSite);

    So far I am able to take the Live Site menu item away, then add my custom menu item, then add the Live Site menu item back. 

    My Problem is that I'm not sure how to add submenu items to my custom menu item, & have it function the same way the built in submenu items do (highlighted when viewing that menu items page).  Lines 12 - 19 is where I was trying to add submenus for my new top nav menu item.

    Also, is the code above the best way to go about this or should I go about this another way?

    Thanks for any help!

    Brian
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    28 Oct 2010
    Link to this post
    Hello Brian,

    You could take a look at this post.

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Brian
    Brian avatar
    31 posts
    Registered:
    25 Jun 2009
    29 Oct 2010
    Link to this post

    Hey Ivan,

    Thanks for the reply.

    For some reason I still cannot get this to work.  Attached is a screenshot of what I have so far.

    I've been able to add the App Configuration menu item in Level 0 of the Main Menu.  When I click on the App Configuration menu item, I receive the page that I expect, but I cannot get Level 1 menu items to show under the App Configuration tab nor can I get the App Configuration menu item to become highlighted.  It just shows a blank space where the level 1 menu items should appear. 

    Here is my MainMenu_DataBound method:

    01.protected void MainMenu_DataBound(object sender, EventArgs e)
    02.{
    03.  // Add Custom Tabs
    04.  RadTab tabAppConfigs = new RadTab();
    05.  tabAppConfigs.Text = "App Configuration";
    06.  tabAppConfigs.NavigateUrl = "~/Sitefinity/Admin/CmsAdmin/AppConfigGeneral.aspx";
    07.  MainMenu.Tabs.Add(tabAppConfigs);
    08.  
    09.  System.Collections.Generic.IList<Telerik.Web.UI.RadTab> tabList = MainMenu.GetAllTabs();
    10.  bool pass = false;
    11.  foreach (RadTab tb in tabList)
    12.  {
    13.    if (!pass && tb.Text == "App Configuration")
    14.    {
    15.    RadTab tab = new RadTab();
    16.    tab.NavigateUrl = "~/Sitefinity/Admin/CmsAdmin/AppConfigGeneral.aspx";
    17.    tab.Text = "AppConfig General";
    18.    tb.Tabs.Add(tab);
    19.        pass = true;
    20.     }
    21.  }
    22.  
    23.  if (!String.IsNullOrEmpty(this.currentTab))
    24.       SetCurrentTab(this.MainMenu.Tabs, this.currentTab);
    25.}

    Here is the code I have in my AppConfigGeneral.aspx.cs file:

    01.using System;
    02.using System.Data;
    03.using System.Configuration;
    04.using System.Collections;
    05.using System.Web;
    06.using System.Web.Security;
    07.using System.Web.UI;
    08.using System.Web.UI.WebControls;
    09.using System.Web.UI.WebControls.WebParts;
    10.using System.Web.UI.HtmlControls;
    11.  
    12.using Telerik.Cms.Web;
    13.using Telerik.Cms.Web.UI;
    14.  
    15.public partial class Sitefinity_Admin_CmsAdmin_AppConfigGeneral : AdminPage
    16.{
    17.    public override string MenuItemName
    18.    {
    19.        get { return "admin_appconfiggeneral"; }
    20.    }
    21.  
    22.    protected void Page_Load(object sender, EventArgs e)
    23.    {
    24.  
    25.    }
    26.}

    Thanks again for any help you can provide.

    Brian
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    01 Nov 2010
    Link to this post
    Hi Brian,

    Could you observe the HTML of the menu and see whether the is not a rule that hides the items on the second level of RadTab items? If so remove the rule that hides your item.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Brian
    Brian avatar
    31 posts
    Registered:
    25 Jun 2009
    02 Nov 2010
    Link to this post
    Hey Ivan,

    Thanks for the advise but I didn't put any rule in to hide the level 2 menu items.  Every other tab is working fine except for the custom one I created.

    Is it safe to say that the above code should generate a new menu item with sub menu items.

    I'll play around with it somemore & if I can't get it working I'll go another route.
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    02 Nov 2010
    Link to this post
    Hello Brian,

    The code generates a new tab which you can observe from the RadTab collection on when you make a request to the backend. Most probably something hides your tab.

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Brian
    Brian avatar
    31 posts
    Registered:
    25 Jun 2009
    03 Nov 2010
    Link to this post
    Ivan,

    Thank you for your time troubleshooting my issue.  Ends up I wasn't hiding the level 2 menu items, I was not (and didn't know to ) assign the level 1 & level 2 menu items a value.

    For anyone else looking to add a new top level menu item with child menu items to the admin menu, below are the steps I took to get this done:

    1. I added a method in /Sitefinity/Admin/Admin.Master.cs to first remove the "Live Site" tab (cause I think that should be at the end), then add my custom Level 1 menu item followed by it's child menu items.  I then called my new method in MainMenu_DataBound before we set the current tab.

    Here is my added method (noting that I created two additional pages named AppConfigGeneral.aspx & AppConfigAdvanced.aspx that inherit the admin.master page which I provide the code for later):

    private void AddCustomAdminNavItems()
    {
      // Remove Live Site Tab
      // Just looks better if this is last.  We will add it back in after adding our custom nav items
      RadTab tabLiveSite = new RadTab();
      tabLiveSite = MainMenu.Tabs.FindTabByText("Live Site");
      MainMenu.Tabs.Remove(tabLiveSite);
      
      // Add Custom Parent Tab
      RadTab tabAppConfigs = new RadTab();
      tabAppConfigs.Text = "App Configuration";
      tabAppConfigs.Value = "mnu_appconfiguration";
      tabAppConfigs.NavigateUrl = "~/Sitefinity/Admin/CmsAdmin/AppConfigGeneral.aspx";
      MainMenu.Tabs.Add(tabAppConfigs);
      
      // Add Child tabs to custom parent tab
      System.Collections.Generic.IList<Telerik.Web.UI.RadTab> tabList = MainMenu.GetAllTabs();
      bool pass = false;
      foreach (RadTab tb in tabList)
      {
        if (!pass && tb.Text == "App Configuration")
        {
          RadTab tab = new RadTab();
          tab.NavigateUrl = "~/Sitefinity/Admin/CmsAdmin/AppConfigGeneral.aspx";
          tab.Text = "AppConfig General";
          tab.Value = "mnu_appconfiguration_appconfiggeneral";
          tb.Tabs.Add(tab);
      
          RadTab tab1 = new RadTab();
          tab1.NavigateUrl = "~/Sitefinity/Admin/CmsAdmin/AppConfigAdvanced.aspx";
          tab1.Text = "AppConfig Advanced";
          tab1.Value = "mnu_appconfiguration_appconfigadvanced";
          tb.Tabs.Add(tab1);
      
          pass = true;
        }
      }
      
      // Add the Live Site tab back in
      MainMenu.Tabs.Add(tabLiveSite);
    }

    2. I then called my new method during the MainMenu_DataBound method in admin.master:

    protected void MainMenu_DataBound(object sender, EventArgs e)
    {
      // Add Custom Tabs
      AddCustomAdminNavItems();
      
      if (!String.IsNullOrEmpty(this.currentTab))
        SetCurrentTab(this.MainMenu.Tabs, this.currentTab);
    }

    3. Then I created the AppConfigGeneral.aspx & AppConfigAdvanced.aspx pages.  The ContentPlaceHolder1 Content element for both aspx files looked like this:

    <asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
        <div id="main">
            <div class="in">
            <div class="ContorlPanelTitle"><h1>TEST</h1></div>
                  <asp:TextBox  runat="server" ID="tb1" />
            </div>
        </div>
        <div id="subnav">
            <div class="in">
                   
                <h3> LEFT SIDE</h3
            </div>
        </div>
        <div class="clear width"><!-- --></div
    </asp:Content>


    Here is the code behind file for AppConfigGeneral.aspx:

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
      
    using Telerik.Cms.Web;
    using Telerik.Cms.Web.UI;
      
    public partial class Sitefinity_Admin_CmsAdmin_AppConfigGeneral : AdminPage
    {
        public override string MenuItemName
        {
            get { return "appconfiguration_appconfiggeneral"; }
        }
      
        protected void Page_Load(object sender, EventArgs e)
        {
              
        }
          
    }

    Notice the "public override string MenuItemName" method, that matches the value for this tab in the AddCustomAdminNavItems method in Admin.Master.cs.

    Here is the code behind for the AppConfigAdvanced.aspx file:

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
      
    using Telerik.Cms.Web;
    using Telerik.Cms.Web.UI;
      
    public partial class Sitefinity_Admin_CmsAdmin_AppConfigAdvanced : AdminPage
    {
        public override string MenuItemName
        {
            get { return "appconfiguration_appconfigadvanced"; }
        }
      
        protected void Page_Load(object sender, EventArgs e)
        {
      
        }
    }


    Only change is the MenuItemName method return.

    4. Lastly, If your viewing the AppConfigGeneral.aspx or the AppConfigAdvanced.aspx HTML source code, you will notice they are calling the appconfiguration.css stylesheet, so I created a stylesheet named appconfiguration.css in /Sitefinity/Admin/Themes/Default/ & inserted the below code:

    @import url(reset.css);
    @import url(global1.css);

    The attached screenshot is the outcome of the above code.
Register for webinar
7 posts, 0 answered