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

Forums / Developing with Sitefinity / Customize Menu Items in Sitefinity with Title and Description

Customize Menu Items in Sitefinity with Title and Description

6 posts, 0 answered
  1. Prateek
    Prateek avatar
    12 posts
    Registered:
    11 Sep 2012
    21 May 2013
    Link to this post
    I need to customize my navigation menu items. I need to have the second level items with Title and Description. Attached is the image how it should look like, also the current version is attached.
    Currently I have added the Navigation Widget in my page with Horizontal with DropDown. There is also a custom template for little changes. 

    Here is it:

    <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" ShowStartingNode="false" />
    <telerik:RadMenu ID="Menu" runat="server" Skin="" ExpandAnimation-Type="None" CollapseAnimation-Type="None" MaxDataBindDepth="2" DataSourceID="SitemapDataSource1" CssClass="RadMenu_mainmenu" >
    </telerik:RadMenu>

    Please help me with this. The description added can come from the Description of the Page in backend.

    Thanks!
  2. Prateek
    Prateek avatar
    12 posts
    Registered:
    11 Sep 2012
    22 May 2013
    Link to this post
    Can someone help me with this ??? its kinda urgent....
  3. Prateek
    Prateek avatar
    12 posts
    Registered:
    11 Sep 2012
    23 May 2013 in reply to Prateek
    Link to this post
    Also, I want to know how to use the SitefinitySiteMapDataSource. This comes from Telerik.Sitefinity.Web.UI.NavigationControls. But this dll file is not present in my bin. Where can I get this file ??
  4. Jen Peleva
    Jen Peleva avatar
    568 posts
    Registered:
    10 Nov 2016
    24 May 2013
    Link to this post
    Hello Prateek,

    Here's a sample template for the default navigation, where on ItemDataBound you can add the Page description to each item and achieve the desired result:
     .ascx

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="RadMenu2.ascx.cs" Inherits="SitefinityWebApp.RadMenu2" %>
    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.NavigationControls"
        TagPrefix="sfMap" %>
     
    <telerik:RadMenu ID="Menu" runat="server" Skin="" ExpandAnimation-Type="None" CollapseAnimation-Type="None" MaxDataBindDepth="2" CssClass="RadMenu_mainmenu" OnItemDataBound="Menu_ItemDataBound" >
    </telerik:RadMenu>


    code-behind
    using Telerik.Web.UI;
     
    namespace SitefinityWebApp
    {
        public partial class RadMenu2 : System.Web.UI.UserControl
        {
            protected void Page_Load(object sender, EventArgs e)
            {
     
            }
     
            protected void Menu_ItemDataBound(object sender, Telerik.Web.UI.RadMenuEventArgs e)
            {
                var item = e.Item as RadMenuItem;
                if (item != null)
                {
                    var pageNode = item.DataItem as PageSiteNode;
                    var page = App.WorkWith().Pages().Where(p => p.Title == pageNode.Title).Get().FirstOrDefault();
                    var description = page.Page.Description[CultureInfo.CurrentUICulture];
                    item.Text += " " + description;
                }
            }
        }
    }

    As for your question about SitefinitySiteMapDataSource. We strongly recommend you to use it when creating custom navigation controls, because handles the logic for permissions, show in navigation and many other. Also it relies on caching and will not go to the database each time a page is requested, to get pages from the Sitemap (which is really good for performance). 

    Regards,
    Jen Peleva
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Prateek
    Prateek avatar
    12 posts
    Registered:
    11 Sep 2012
    24 May 2013
    Link to this post
    Hello Jen,

    I implemented the menu as you said but I get an error:

    Telerik.Sitefinity.Pages.Model.PageNode, Telerik.Sitefinity.Model was not granted View in Pages for principals with IDs 00000000-0000-0000-0000-000000000000

    And this error comes from this line:
    var page = App.WorkWith().Pages().Where(p => p.Title == pageNode.Title).Get().FirstOrDefault();

    Please help.

    Thanks!
  6. Pavel Benov
    Pavel Benov avatar
    341 posts
    Registered:
    14 Mar 2016
    29 May 2013
    Link to this post
    Hi Prateek,

    Most probably the error is thrown because you are not logged in or you are, but with a user that does not have permission to view the page. This has been discussed previously in the forums. Please take a look at the following threads for further information:


    Regards,
    Pavel Benov
    Telerik
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
6 posts, 0 answered