2

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)

1

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);
    }
}    
  • You might have to play around with which provider to query. There were a few in the web.config that reference the taxonomy service in addition to the one I put in the code above: GlobalNavigationSwitchableProvider, CurrentNavigationSwitchableProvider, and CurrentNavigationTaxonomyProvider. – Steve Lineberry Oct 9 '14 at 15:25
  • 1
    Hi Steve. Thanks for the new angle. I can get the correct provider, but the title is read only, so even if I get the correct node, I cant change it. I have also tried create new ones, but TaxonomySiteMapNode has no (public) contstructor. (and there goes my initial workaround as well). Im leaning towards collecting the info I need server side, inject it to client and replace labels using js. – Cowborg Oct 10 '14 at 12:10
  • 1
    ...actually I was hoping for a "correct"/official way to do this. What I really want to do is show specific language dep on user (from connected term), maybe I should take a step back... – Cowborg Oct 10 '14 at 12:13
  • I'm looking at the code for the taxonomysitemapnode and I am not seeing why the title would be readonly. Could you create your own sitemapnode and just copy the values over? SiteMapNode node = new SiteMapNode(this, key, url, title); – Steve Lineberry Oct 10 '14 at 13:56
  • 1
    hmm... my mistake, you dont need to return a TaxnomySiteMapNode. As you suggesteed, you could just read from one. However I got into other problem and ended up doing my translations on client side, but Reading data from TaxonomyProvider.... Im marking this as "correct", even though I didnt get all the way, since it answered my question... thanks :) – Cowborg Oct 13 '14 at 16:25
0

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

  • TaxonomySiteMapProvider is sealed – Cowborg Oct 9 '14 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.