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

Forums / Developing with Sitefinity / Using the SiteMap

Using the SiteMap

22 posts, 0 answered
  1. fregas baratis
    fregas baratis avatar
    185 posts
    Registered:
    14 Nov 2002
    03 Jul 2007
    Link to this post
    I just upgraded my SF RC2 to the release version. 

    In the master page, i was referencing a RadPanel, which binds to the sitemapdatasource.  On each ItemDataBound, I would check the Sitemap to see if this panel item was the one representing the current node (SiteMap.CurrentNode) and if it was, I open that panel item and its parents, so the user can see where they are now.

    This quit working after the upgrade.  Now when I use SiteMap.CurrentNode in the master page, its always null.  Is there a workaround for this?

    Thanks,
    Craig
  2. Vassil Daskalov
    Vassil Daskalov avatar
    261 posts
    Registered:
    18 May 2013
    04 Jul 2007
    Link to this post
    Hello fregas baratis,

    I was not able to reproduce your problem. I created sample master page file with RadPanelBar and SiteMapDataSource control in it and everything works fine when using it in a page. You can find the file attached. The only situation in which the CurrentNode is null is when you use it in a template which is the expected behavior.

    Regards,
    Vassil Daskalov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. fregas baratis
    fregas baratis avatar
    185 posts
    Registered:
    14 Nov 2002
    06 Jul 2007
    Link to this post
    What about on a page that is non-navigable?  I am trying to do this:

    SiteMap.CurrentNode


    and getting null for currentNode.  I remember this used to be an issue in the beta version, but i thought it had been fixed.  If i can't use the sitemap, how do i get information about the current page programmatically if its non-navigable.

    Thanks,
    Craig
  4. Sean
    Sean avatar
    271 posts
    Registered:
    31 May 2006
    08 Jul 2007
    Link to this post
    Hi Craig,

    For non-navigable pages you need to not use the default provider eg.

     SiteMap.Providers["AllPages"].CurrentNode

    By default though the "AllPages" provider isn't in the web.config anymore for new Projects.  You will need to ensure you web.config sitemap looks like this:

       <siteMap defaultProvider="CmsSiteMapProvider" enabled="true"
          <providers> 
            <clear /> 
            <add name="CmsSiteMapProvider" description="Displays Cms Pages" type="Telerik.Cms.Web.CmsSiteMapProvider" /> 
            <add name="AllPages" navigable="false" description="Displays Cms Pages" type="Telerik.Cms.Web.CmsSiteMapProvider" /> 
          </providers> 
        </siteMap> 

    Otherwise the code sample I gave you won't work.

    Sean
  5. Vlad
    Vlad avatar
    498 posts
    Registered:
    19 Jun 2017
    09 Jul 2007
    Link to this post
    Hi,

    Currently the SiteMap.CurrentNode property is implemented to return the current node if it is navigable or the first navigable parent node. Perhaps, in your case it returns null, because there is no navigable parent.
    But it seems that this is not the most appropriate behavior of the SiteMapProvider, so we decided to make a few changes for the upcoming service pack. The SiteMap provider should always contain all pages. Also, the navigable controls should return only navigable pages and the SiteMap.CurrentNode property should return the current page node no matter if it is set as navigable or not.
    We think that these improvements will cover more scenarios.

    All the best,
    Vlad
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  6. fregas baratis
    fregas baratis avatar
    185 posts
    Registered:
    14 Nov 2002
    09 Jul 2007
    Link to this post
    Yeah, i think thats the most intuitive way to implement the sitemap.  Chances are is your're accessing the sitemap programmatically, you'll need to know about navigable AND non-navigable pages.

    I remember using the provider["AllPages"] method mentioned above, but i thought its use was deprecated in the release version.  Glad you're changing this in the SP1.

    Thanks,
    Craig
  7. fregas baratis
    fregas baratis avatar
    185 posts
    Registered:
    14 Nov 2002
    09 Jul 2007
    Link to this post
    Crap.

    I tried using the "AllPages" provider mentioned above, and it partially works.  I can see all the pages, but CurrentNode is still null while i'm on a non-navigable page.  So i can't tell what page i'm on. 

    When is the service pack coming out? Or is it already.

    Thanks,
    Craig

  8. Rebecca
    Rebecca avatar
    536 posts
    Registered:
    24 Sep 2012
    09 Jul 2007
    Link to this post
    Hi fregas baratis,

    SP2 should be out by the end of the week.

    Best wishes,
    Rebecca
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  9. fregas baratis
    fregas baratis avatar
    185 posts
    Registered:
    14 Nov 2002
    09 Jul 2007
    Link to this post
    Ok, so i guess i should upgrade to SP2, not SP1? 

    Is there another way i can get information about pages, and the current page i'm on,  perhaps thru the Nolics API?

    Thanks,
    Craig
  10. Bob
    Bob avatar
    330 posts
    Registered:
    30 Dec 2016
    09 Jul 2007
    Link to this post
    Hi Craig,

    Here is an example:
    using Telerik.Cms;  
    using Telerik.Cms.Web;  
     
    ...  
     
    CmsManager manger = new CmsManager();  
    ICmsPage page = manger.GetPage(CmsUrlContext.Current.PageID) as ICmsPage;  
    if (page != null)  
    {  
        string menuLable = page.MenuName;  
    }  
     

    I hope this helps.

    Sincerely yours,
    Bob
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  11. Mat
    Mat avatar
    23 posts
    Registered:
    05 Nov 2006
    11 Jul 2007
    Link to this post

    Hi,

    I’ve got a similar problem with the sitemap and here it is.

    The property SiteMap.CurrentNode works just fine until I created or edited a page from a different language (not default language). After that, the property CurrentNode return always null at every page until I restart the worker process. A bug?

    Regards,
    Mat

  12. Vassil Daskalov
    Vassil Daskalov avatar
    261 posts
    Registered:
    18 May 2013
    12 Jul 2007
    Link to this post
    Hi Mat,

    Seems that I can not reproduce the issue. Would you try this with the new service pack which will be shipped today.

    Greetings,
    Vassil Daskalov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  13. Mat
    Mat avatar
    23 posts
    Registered:
    05 Nov 2006
    16 Jul 2007
    Link to this post

    Hi Vassil,

    After hours of testing with SP2 I’ve got something.

    I created a new empty project and integrated your code example from an earlier post (FregasSample.zip). So far it works fine with one or different languages.

    Now, when I set an offset to the datasource I’m having the problem earlier described.
    <asp:SiteMapDataSource ID="sitemap" runat="server" ShowStartingNode="false" StartingNodeOffset="1" />

    Can you try it again, please? Is there a way around?

    Thanks,
    Mat

  14. Vassil Daskalov
    Vassil Daskalov avatar
    261 posts
    Registered:
    18 May 2013
    16 Jul 2007
    Link to this post
    Hello Mat,

    This time I was able to reproduce the problem and it seems that there is no need to set the StartingNodeOffset to get it. Thank you very much for pointing this issue, it will be fixed for the next release.

    Sorry for the inconvenience caused. Your Telerik points were updated.

    Regards,
    Vassil Daskalov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  15. Mat
    Mat avatar
    23 posts
    Registered:
    05 Nov 2006
    17 Jul 2007
    Link to this post
    Hi,

    any ideas on the next release date?

    Mat
  16. Pepi
    Pepi avatar
    981 posts
    Registered:
    31 Jan 2017
    18 Jul 2007
    Link to this post
    Hi Mat,

    The next release is planned for mid September.

    Kind regards,
    Pepi
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  17. bnye
    bnye avatar
    332 posts
    Registered:
    22 Sep 2005
    18 Jul 2007
    Link to this post
    I don't know if this has come up already, but the sitemap can get the currentnode when non-navigable and it can get the parentnode of that node. But if you try to get the childnodes of the parentnode of the currentnode it will only show the navigable ones. That was a little convoluted. Let me know if that doesn't make sense.
  18. Bob
    Bob avatar
    330 posts
    Registered:
    30 Dec 2016
    19 Jul 2007
    Link to this post
    Hi Ben,

    This behavior is by design. We couldn’t come up with a better idea as non-navigable pages should not appear in navigational controls and at the same time if a navigational control is placed on a non-navigable page may need current node to display correctly.

    If you have a better idea, you are very welcome to share it with us.

    All the best,
    Bob
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  19. bnye
    bnye avatar
    332 posts
    Registered:
    22 Sep 2005
    19 Jul 2007
    Link to this post
    Oh I see. No I trust you Bob. I will find another work around for my needs. I was trying to show a sidenavigation that shows the current page siblings even if they are non navigable. The reason was to keep them out of the actual Site Map but still have then in the sidenavigation.

    Sincerely,
  20. Mat
    Mat avatar
    23 posts
    Registered:
    05 Nov 2006
    08 Aug 2007
    Link to this post
    Hi,

    I made a simple custom dialog for the editor to insert internal pages as a hyperlink.

    Now my problem is, I can't display sitemaps for other available languages. I use the radTreeview with the SiteMapDataSource. What do I have to do, to get it work?

    Any help is appreciated.

    Thanks,
    Mat
  21. Vlad
    Vlad avatar
    498 posts
    Registered:
    19 Jun 2017
    08 Aug 2007
    Link to this post
    Hello Mat,

    Our CmsSiteMapProvider returns sitemap nodes based on the current CultureInfo. So your task requires to change current CultureInfo for the time of binding treeview control and then set it back to the original CultureInfo.

    The following implementation of user control demonstrates displaying sitemap for other languages:

    LangSitemap.ascx:
    <%@ Control Language="C#" AutoEventWireup="true" CodeFile="LangSitemap.ascx.cs" Inherits="UserControls_LangSitemap" %> 
    <%@ Register Assembly="RadTreeview.Net2" Namespace="Telerik.WebControls" TagPrefix="radTV" %> 
     
    <div style="clear:both;">  
        <asp:DropDownList ID="ddlLanguages" runat="server" AutoPostBack="true" /> 
        <asp:SiteMapDataSource ID="SitemapDataSource1" runat="server" ShowStartingNode="false" /> 
        <radTV:RadTreeview ID="RadTreeview1" runat="server" DataSourceID="SitemapDataSource1"></radTV:RadTreeview> 
    </div> 

    LangSitemap.ascx.cs:
    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 System.Globalization;  
    using Telerik.Localization;  
    using System.Threading;  
    using Telerik.Cms.Web;  
     
    public partial class UserControls_LangSitemap : System.Web.UI.UserControl  
    {  
        protected override void OnInit(EventArgs e)  
        {  
            base.OnInit(e);  
            ddlLanguages.SelectedIndexChanged += new EventHandler(ddlLanguages_SelectedIndexChanged);  
        }  
     
        void ddlLanguages_SelectedIndexChanged(object sender, EventArgs e)  
        {  
            // save the original current CultureInfo  
            CultureInfo currentCulture = Thread.CurrentThread.CurrentUICulture;  
              
            // gets the new CultureInfo and sets it as a current  
            CultureInfo selectedCulture = CultureInfo.GetCultureInfo(ddlLanguages.SelectedValue);  
            Thread.CurrentThread.CurrentUICulture = selectedCulture;  
            HttpContext.Current.Items[UrlHelper.CultureKey] = selectedCulture;   
              
            // bind treeview  
            this.RadTreeview1.DataBind();  
              
            // sets back the original current CultureInfo  
            HttpContext.Current.Items[UrlHelper.CultureKey] = currentCulture;  
            Thread.CurrentThread.CurrentUICulture = currentCulture;  
        }  
     
        protected void Page_Load(object sender, EventArgs e)  
        {  
            if (!IsPostBack)  
            {  
                foreach (CultureInfo info in LocalizationManager.Cultures)  
                {  
                    ListItem item = new ListItem(info.NativeName, info.Name);  
                    if (info.Equals(CultureInfo.CurrentUICulture))  
                        item.Selected = true;  
                    ddlLanguages.Items.Add(item);  
                }  
            }  
        }  
    }  
     


    Best wishes,
    Vlad
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  22. Mat
    Mat avatar
    23 posts
    Registered:
    05 Nov 2006
    08 Aug 2007
    Link to this post
    Hello Vlad,

    Thanks for the help, it works perfect.

    Greetings,
    Mat
Register for webinar
22 posts, 0 answered