More in this section

Forums / Developing with Sitefinity / MainMenuDataSource

MainMenuDataSource

7 posts, 0 answered
  1. Tim
    Tim avatar
    156 posts
    Registered:
    23 Sep 2007
    09 Oct 2007
    Link to this post
    Sitefinity Team,

    On the Admin.master page, there is datasource called MainMenuDataSource. I am just wondering if you could let me know where the MainMenuDataSource gets data from, either from table in the database or in the web.config file. If it gets data from table from database, please let me know which table.
     

    Thanks in advance
    Tim
  2. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    10 Oct 2007
    Link to this post
    Hi Tim,

    In the attachment you will find 2 files - MainMenuDataSource.cs (contains the MainMenuDataSource class that represents the data source for binding the main navigation menu) and MainMenuSourceView.cs (contains MainMenuSourceView that defines the capabilities of MainMenuDataSource control). Please investigate the ExecuteSelect method in MainMenuSourceView that retrieves the data from the underlying data store and returns it as an IEnumerable object. You could see that a DataTable object is created and after that are setting the values for each column in a given row. Also, you will notice that part of the data is hardcoded (like Dashboard, Pages, Modules, Files, Administration and Live Site sections) and the other part is getting dynamically from the web.config (as separate web modules in Modules section and services in Administration section). Modules and services are configured under the <framework> section in the web.config.

    Please, contact us if you come up with other questions.

    Greetings,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. Tim
    Tim avatar
    156 posts
    Registered:
    23 Sep 2007
    10 Oct 2007
    Link to this post
    Hi Pepi,

    By looking at your source code, I guess there is no way I can change the name like Files to Directory.  Am I right?

    Please let me know
    Tim
  4. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    10 Oct 2007
    Link to this post
    Hello Tim,

    The workaround is to implement your own DataSourceControl and DataSourceView that will inherit MainMenuDataSource and MainMenuSourceView class and override ExecuteSelect method where you should modify the existing view. For example, you could create ExtMainMenuDataSource.cs file in the ~/App_Code folder:

    using System; 
    using System.Data; 
    using System.Configuration; 
    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.UI; 
    using Telerik.Cms.Web; 
     
    namespace Controls 
        /// <summary> 
        /// Summary description for ExtMainMenuDataSource 
        /// </summary> 
        public class ExtMainMenuDataSource : MainMenuDataSource 
        { 
            public ExtMainMenuDataSource() 
            { 
            } 
     
            protected override DataSourceView GetView(string viewName) 
            { 
                if (this.sourceView == null
                    this.sourceView = new ExtMainMenuSourceView(this, String.Empty); 
                return this.sourceView; 
            } 
     
            private ExtMainMenuSourceView sourceView; 
        } 
     
        public class ExtMainMenuSourceView : MainMenuSourceView 
        { 
     
            public ExtMainMenuSourceView(IDataSource owner, string name) 
                : base(owner, ExtMainMenuSourceView.DefaultViewName) 
            { 
            } 
     
            protected override System.Collections.IEnumerable ExecuteSelect(DataSourceSelectArguments arguments) 
            { 
                DataView view = (DataView)base.ExecuteSelect(arguments); 
     
                foreach (DataRow row in view.Table.Rows) 
                { 
                    if (row["Value"].ToString() == "mnu_files"
                    { 
                        row["Text"] = "Directory"
                    } 
                } 
     
                return view; 
            } 
     
            public static string DefaultViewName = "ExtMainMenuView"
        } 

    After that you need to change DataSourceControl object in ~/Sitefinity/Admin/Admin.master:

    <%@ Register Namespace="Controls" TagPrefix="app" %> 
    ... 

    <div class="tabstripWrapper"
         <radts:radtabstrip id="MainMenu" SkinsPath="~/Sitefinity/Admin/Themes/Default/Skins/Tabstrip" Skin="Sitefinity" runat="server" meta:resourcekey="RadTabStrip1Resource1" DataFieldID="ID" DataFieldParentID="ParentID" DataNavigateUrlField="NavigateUrl" DataSourceID="MainMenuDataSource1" DataTextField="Text" DataValueField="Value" OnDataBound="MainMenu_DataBound" CausesValidation="false"></radts:radtabstrip> 
         <app:ExtMainMenuDataSource id="MainMenuDataSource1" runat="server"></app:ExtMainMenuDataSource> 

    </div> 
    ... 

    Hope this helps.

    Best wishes,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Tim
    Tim avatar
    156 posts
    Registered:
    23 Sep 2007
    10 Oct 2007
    Link to this post
    Hi Pepi,

    I will give a try later and will keep you updated.

    By the way I put another thread regarding tag&categories in the control section. I am just wondering if there is way to change the name because a lot of end users get confused and they don't know what to do with it.

    Thanks
    Tim
  6. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    11 Oct 2007
    Link to this post
    Hello Tim,

    You could find the answer to your Tags & Categories question in this thread. Unfortunately, there is no way to change the name of this section for now. You could add a new section containing the same controls but you could not rename or remove the existing one. If you decide that adding a new section is a good solution, please follow the instructions to achieve this:

    1. Find the <toolboxControls> section in the web.config file.
    2. Add the following lines:

    <add name="Tags List" section="Your section name" type="Telerik.Cms.Engine.WebControls.Tags.TagsList, Telerik.Cms.Engine" /> 
    <add name="Categories List" section="Your section name" type="Telerik.Cms.Engine.WebControls.Categories.CategoriesList, Telerik.Cms.Engine" /> 

    Best wishes,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  7. Tim
    Tim avatar
    156 posts
    Registered:
    23 Sep 2007
    11 Oct 2007
    Link to this post
    Hi Pepi,

    It's better than nothing.

    Thanks a lot
    Tim
Register for webinar
7 posts, 0 answered