Tell me more ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am creating a menu control that read terms from taxonomy term store. Get termSet and term is straight forward

        using (SPSite siteCollection = new SPSite(siteCollecitonUrl))
        {
            TaxonomySession taxSession = new TaxonomySession(siteCollection);
            TermStore taxStore = taxSession.TermStores[0];
            Group taxGroup = taxStore.GetSiteCollectionGroup(siteCollection);
            TermSet termSet = taxGroup.TermSets[strTermSetsName];

            foreach (term in termSet.terms)
            {
                term.???
            }
        }

but how to retrieve friendly URL or simple url link?

I could not find a property or method.

Thank you.

share|improve this question

1 Answer

up vote 2 down vote accepted

You have to use NavigationTerm

To Create Term set:

  NavigationTerm term2 = navTermSet.CreateTerm("Term 2", NavigationLinkType.FriendlyUrl,
                    term2Guid);

/// Verify that the NavigationTermSetView is being applied correctly.

 Assert.AreEqual(web.ServerRelativeUrl + "/term-2", term2.GetResolvedDisplayUrl(null).ToString());

In order to add new terms to navigation term set, you can use the following code:

// Obtain navigation term set
NavigationTermSet navigationTermSet = NavigationTermSet.GetAsResolvedByWeb(termSet, web, "GlobalNavigationTaxonomyProvider");
// Specify that this term set can be used for site navigation
navigationTermSet.IsNavigationTermSet = true;
// Creates new term pointing to an already existing URL outside of SharePoint
NavigationTerm term = navigationTermSet.CreateTerm("Bing Search", NavigationLinkType.SimpleLink, Guid.NewGuid());
term.SimpleLinkUrl = "http://www.bing.com/";
// Creates new term pointing to an existing SharePoint page
NavigationTerm term2 = navigationTermSet.CreateTerm("Target page", NavigationLinkType.FriendlyUrl, Guid.NewGuid());
term2.TargetUrl.Value = "~site/Pages/TargetPage.aspx";

Hope this helps

http://msdn.microsoft.com/en-us/library/jj163978.aspx

share|improve this answer
Anuja, thank you for the comment but it did not help. My question is if I have term store setup and simply want to retrieve term properties especially friendly URL and simple link. I do not like to create new terms by using NavigationTerm. – wming Feb 8 at 17:06
Hell Anuja. Your comment did not answer my question but point to the right direction. I managed to retrieve those properties by using NavigationTermSet. – wming Feb 8 at 18:37
Glad that it helps to you – Anuja Feb 10 at 18:53

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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