PotalSiteMapProvider doesn't return pages

771 views Asked by At

PotalSiteMapProvider doesn't return pages. I use the code as follows:

        PortalSiteMapProvider prov = PortalSiteMapProvider.CurrentNavSiteMapProviderNoEncode;
        prov.DynamicChildLimit = 0;
        prov.IncludeSubSites = PortalSiteMapProvider.IncludeOption.Always;
        prov.IncludePages = PortalSiteMapProvider.IncludeOption.Always;
        prov.IncludeHeadings = true;
        prov.IncludeAuthoredLinks = true;
        SiteMapNode root = prov.RootNode;

        //prov.IncludePages = PortalSiteMapProvider.IncludeOption.Always;
        SiteMapNodeCollection collection = prov.GetChildNodes(root);


        foreach (SiteMapNode thisNode in collection)
        {
            SiteMapNodeCollection thisCollection;
            if (thisNode.GetType() == typeof(PortalWebSiteMapNode))
            {
                prov.IncludePages = PortalSiteMapProvider.IncludeOption.Always;
                thisCollection = prov.GetChildNodes((PortalWebSiteMapNode)thisNode);
            }
        }

As I look it through debugger, thisCollection never has any children, though thisNode is a SubSite Node that has pages. What am I doing wrong and how can I get pages, that are in that node? Thanks!

1

There are 1 answers

0
jgriffith On

This is the code I used in a project awhile back. It seemed to pull subpages properly for me.

PortalSiteMapProvider portalProvider = (PortalSiteMapProvider)SiteMap.Providers["CurrentNavSiteMapProviderNoEncode"];
PortalSiteMapNode currentNode = portalProvider.CurrentNode as PortalSiteMapNode;
foreach (SiteMapNode childNode in currentNode.ChildNodes) {
   ...
}