Customize Menu Items in Sitefinity with Title and Descriptio

Posted by Community Admin on 04-Aug-2018 22:50

Customize Menu Items in Sitefinity with Title and Description

All Replies

Posted by Community Admin on 21-May-2013 00:00

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!

Posted by Community Admin on 22-May-2013 00:00

Can someone help me with this ??? its kinda urgent....

Posted by Community Admin on 23-May-2013 00:00

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 ??

Posted by Community Admin on 24-May-2013 00:00

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

Posted by Community Admin on 24-May-2013 00:00

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!

Posted by Community Admin on 29-May-2013 00:00

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

This thread is closed