More in this section

Forums / Developing with Sitefinity / Sitemap contains links : Even after "Show in navigation" unchecked

Sitemap contains links : Even after "Show in navigation" unchecked

6 posts, 1 answered
  1. Justin Manjooran
    Justin Manjooran avatar
    17 posts
    Registered:
    24 Sep 2009
    02 Jul 2011
    Link to this post
    Installed Sitefinity_4.1.1501.0

    Sitemap contains links : Even after "Show in navigation" unchecked. Why?

    <asp:SiteMapDataSource ID="SiteMapDataSource1" ShowStartingNode="false" runat="server" />
    <radM:RadMenu ID="RadMenu1" runat="server" DataSourceID="SitemapDataSource1" Skin="menu1" >
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    04 Jul 2011
    Link to this post
    Hello Justin,

    Remove SiteMapDataSource from your template and set NavigationControl to use your ascx.

    Best wishes,
    Ivan Dimitrov
    the Telerik team
    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
    Answered
  3. Ben Alexandra
    Ben Alexandra avatar
    215 posts
    Registered:
    15 Sep 2012
    24 Sep 2011
    Link to this post
    I'm not sure I understand.  We also want to use the same code Justin used (as we have code behind that needs to be associated with the menu in order to get images as the first level of nav).

    We got it working fine, but when we add a page to the sitemap and say do not show in nav it still appears in this menu.

    Any other idea? 
  4. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    28 Aug 2017
    26 Sep 2011
    Link to this post
    Hi Ben Alexandra,

    You can follow Ivan's advice and create your control, which you can later set as a template for the Navigation widget in Sitefinity - you simply create the presentation part (ascx) and the codebehind logic of your control, compile it, but you will not be feeding it with a datasource, as you'll specify its application relative path to the Custom Template Path property int eh design setting s of the Navigation widget. This will automatically feed your widget with the datasource provided for all Sitefinity navigation controls, and solve your problems with the ShowInNavigation pages.
    However, if you need to add a datasource declaratively to your control, please use our newly introduced SitefinitySiteMapDataSource control (available since release version Sitefinity 4.2 build 4.2.1650)
    If you're still using a previous version of Sitefinity, where this control is not available, you can still use asp:SiteMapDataSource control and perform the following check in your codebehind:
    ISitefinitySiteMapNode cNode = e.Item.DataItem asISitefinitySiteMapNode;
               PageSiteNode node = (PageSiteNode)cNode;
                  
                if(!node.ShowInNavigation || !node.Visible)
                {
                    e.Item.Visible = false;
                }

    Regards,
    Boyan Barnev
    the Telerik team
    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. Martin Chamorro
    Martin Chamorro avatar
    5 posts
    Registered:
    03 Feb 2010
    04 Oct 2011
    Link to this post
    Hi,

    So I work with Ben from above. We followed your instructions and we were able to create a menu user control, which we applied as a template to the Sitefinity Navigation user control. All of that worked perfectly and the pages that we set to hide in the navigation are now hidden correctly. However, we are having another issue. We want to use images for the RadMenu items rather than text. This works fine with the code we are using in the code behind if we put the menu on the master template. The problem with that method is that we had to use a data source and so we had the original issue with menu items no hiding when they were supposed to. Your solution (i.e., creating a control and using it as a Custom template path) fixes that problem but when put the exact same code behind in that control, the images no longer work. Our menu now just shows text. Here is the markup we used in the .ascx page for the custom template:

    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TopMenuViewCustom.ascx.cs" Inherits="Trakkware.Clients.EasternCurrents.easterncurrents.ca.Sitefinity.UserControls.Trakkware.TopMenuViewCustom" %>
    <telerik:RadMenu ID="EasternCurrentsTopMenu" runat="server"></telerik:RadMenu>

    And here is the code we are using in the code behind:

    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using Telerik.Sitefinity.Web.UI;
    using Telerik.Web.UI;
    using System.IO;
     
    namespace Trakkware.Clients.EasternCurrents.easterncurrents.ca.Sitefinity.UserControls.Trakkware
    {
        public partial class TopMenuViewCustom : System.Web.UI.UserControl
        {
            protected void Page_Load(object sender, EventArgs e)
            {
                // Hide the radmenu in edit mode.
                string path = HttpContext.Current.Request.Url.AbsolutePath;
     
                SiteMapNode smnRoot = SiteMap.RootNode;
                SiteMapNode smnCurrentParent = SiteMap.CurrentNode;
     
                if (path.IndexOf("/Action/Edit") != -1 || path.IndexOf("/Sitefinity") != -1)
                {
                    EasternCurrentsTopMenu.Visible = false;
                }
                else
                {
                    while (smnCurrentParent.ParentNode != smnCurrentParent.RootNode) smnCurrentParent = smnCurrentParent.ParentNode;
                    RadMenuItem item = new RadMenuItem();
                    EasternCurrentsTopMenu.DataBind();
                    smnRoot = smnRoot.ChildNodes[0];
                    while (smnRoot != null)
                    {
                        item = EasternCurrentsTopMenu.FindItemByUrl(ResolveUrl(smnRoot.Url));
                        if (item != null)
                        {
                            String strTitle = smnRoot.Title.ToLower().Replace(" ", "_").Replace("ü", "u").Replace("ä", "a").ToString();
                            String strImageOver = String.Format("~/images/template/menu/{0}-over.jpg", strTitle);
                            String strImage = String.Format("~/images/template/menu/{0}.jpg", strTitle);
     
                            //Added by Ben to see if item exist
                            if (File.Exists(Server.MapPath(strImage)))
                            {
                                if (smnRoot == smnCurrentParent)
                                {
                                    item.ImageUrl = strImageOver;
                                }
                                else
                                {
                                    item.ImageUrl = strImage;
                                }
                                item.HoveredImageUrl = strImageOver;
                            }
                            item.ToolTip = smnRoot.Title.ToString();
                            item.Text = "";
                        }
                        smnRoot = smnRoot.NextSibling;
                    }
                }
            }
        }
    }

    You'll notice we set RadMenuItem item = new RadMenuItem(); and then we assign a string for the item.ImageUrl but the menu still fails to use images. As mentioned earlier, this all works just fine if we create the menu in the master template but not when we create a custom template and apply it to the Sitefinity Navigation control in one of our SF page templates. How can we resolve this?
  6. Boyan Barnev
    Boyan Barnev avatar
    1429 posts
    Registered:
    28 Aug 2017
    07 Oct 2011
    Link to this post
    Hello Martin Chamorro,

    Have you considered the option of upgrading your project to the latest officially supported version? I'm suggesting this, as you could benefit from using our SitefinitySiteMapDatasource control which wraps all the necessary logic (permissions check, ShowInNavigation, Group pages redirect, Group pages with no children etc.) You can use it as a DataSource for your control, and then implement just the logic for assigning an image to an item int he Navigation. You can check a sample of using SitefinitySiteMapDataSource below:
    <%@ Register Assembly="Telerik.Sitefinity" Namespace="Telerik.Sitefinity.Web.UI.NavigationControls" TagPrefix="sfMap" %>
    <sfMap:SitefinitySiteMapDataSource runat="server" ID="SitefinitySiteMapDS" StartingNodeUrl="/Home" />
    <telerik:RadTreeView runat="server" ID="RTV1" DataSourceID="SitefinitySiteMapDS"></telerik:RadTreeView>


    Kind regards,
    Boyan Barnev
    the Telerik team
    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, 1 answered