0

Hi I have created a topNavigation class which implements PortalSiteMapProvider. the problem is that there is duplicated for the root site collection and root site collection contains only itself not other site collections. one of them goes to mydom/sitepages/startpage.aspx and the other one goes to mydom/. I would like to remove that one that goes to mydom/sitepages/startpage.aspx. here is my code: (not publishing sites)

public class RIRTopNavMapProvider : PortalSiteMapProvider
{
    public override System.Web.SiteMapNodeCollection GetChildNodes(System.Web.SiteMapNode node)
    {
        SiteMapNodeCollection nodeColl = new SiteMapNodeCollection();
        PortalSiteMapNode pNode = node as PortalSiteMapNode;
        if (pNode != null)
        {
            if (pNode.Type == NodeTypes.Area && pNode.WebId == SPContext.Current.Site.RootWeb.ID)
            {
                SPWebApplication oWebApplicationCurrent = SPContext.Current.Site.WebApplication;
                        SPSiteCollection collSites = oWebApplicationCurrent.Sites;

                            foreach (SPSite site in collSites) //webApp.Sites)
                            {
                                try
                                {
                                    if (site.RootWeb.DoesUserHavePermissions(SPBasePermissions.ViewPages)) 
                                    {
                                        AddNavNode(nodeColl, site.RootWeb.Title, site.RootWeb.Url);
                                        break;
                                    }
                                }
                                finally
                                {
                                    if (site != null)
                                    {
                                        site.Dispose();
                                    }
                                }
                            }
                          return nodeColl;
            }
            return base.GetChildNodes(pNode);
        }
        return new SiteMapNodeCollection();
    }

    private void AddNavNode(SiteMapNodeCollection nodeColl, string title, string url)
    {
        SiteMapNode navNode = new SiteMapNode(this, title, url, title);
        nodeColl.Add(navNode);
    }
7
  • Make sure you deploy to the site collection root not the site for this, I think that might be the issue.
    – Hugh Wood
    Sep 11, 2012 at 11:54
  • I don't understand exactly what do you mean, the other Site Collection has right TopNavigationbar.
    – Medes
    Sep 11, 2012 at 12:14
  • If you are deploying at site level then it can cause this duplication. Please read this if you don't understand. sharepoint.stackexchange.com/questions/27436/…
    – Hugh Wood
    Sep 11, 2012 at 12:16
  • sorray by my mistake, yes I have used a feature which was web scoped to deploy the navigation bar, however when I change it to Site (site collection) it still renders dubplicate for first page.
    – Medes
    Sep 11, 2012 at 15:16
  • Yes but the url you are deploying to is it a site or a site collection, ie sitecollection sitecollection/site
    – Hugh Wood
    Sep 11, 2012 at 15:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Browse other questions tagged or ask your own question.