문제

Maybe Ive got this wrong, but I was hoping to have a Custom SiteMapProvider(SMP) for my Global Managed Navigation top menu.

I have a managed navigation that reads from my metadataservice and works well. But when I activate the feature that contains my custom (derived from PortalSiteMapProvider), the managed top menu disappears and I have only the "standard menu" that displays the subwebs.

If I set a breakpoint in my custom SMP I only get the subwebs node.

Have I misunderstood this? Im thinking that either you have SPs Taxonomy SMP or you have your custom. I was also hoping to derive from Taxonomy SMP, but I cant find example for that.

So: Is it possible to get the Managed Navigation Nodes and fiddle with the titles, as with a normal SMP?

(If not I can just put a web control in master page that traverses the menu, i e, without any SMP)

도움이 되었습니까?

해결책

Since it's sealed I have another idea.

What I've done before is actually just query another SMP in my custom SMP. This strategy might work for you. You basically just create a wrapper SMP that queries the taxonomy one and modifies the nodes it returns before you return them in your SMP. Below is some sample code.

public class CustomNavProvider : SiteMapProvider
{
    private const string PROVIDERNAME = "GlobalNavigationTaxonomyProvider";

    public override SiteMapNode RootNode
    {
        get
        {
            return SiteMap.Providers[PROVIDERNAME].RootNode;
        }
    }

    public override SiteMapNode CurrentNode
    {
        get
        {
            return SiteMap.Providers[PROVIDERNAME].CurrentNode;
        }
    }

    public override SiteMapNodeCollection GetChildNodes(SiteMapNode parent)
    {
        SiteMapNodeCollection childNodes = new SiteMapNodeCollection();
        if ((parent == null) || (parent.Key == null)) return childNodes;

        foreach (SiteMapNode tempNode in SiteMap.Providers[PROVIDERNAME].GetChildNodes(parent))
        {
            //do stuff with tempNode
            childNodes.Add(tempNode);
        }

        return childNodes;
    }

    public override SiteMapNode FindSiteMapNode(string rawUrl)
    {
        return SiteMap.Providers[PROVIDERNAME].FindSiteMapNode(rawUrl);
    }

    public override SiteMapNode GetParentNode(SiteMapNode node)
    {
        return SiteMap.Providers[PROVIDERNAME].GetParentNode(node);
    }
}    

다른 팁

Did you take a look at inheriting from: Microsoft.SharePoint.Publishing.Navigation.TaxonomySiteMapProvider ??

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 sharepoint.stackexchange
scroll top