Exemplo n.º 1
0
        public void buildItem(HtmlTextWriter writer, Term term)
        {
            var navTerm = NavigationTerm.GetAsResolvedByWeb(term, Site.OpenWeb(),
                                                            StandardNavigationProviderNames.GlobalNavigationTaxonomyProvider);

            buildItem(writer, navTerm);
        }
Exemplo n.º 2
0
        public HtmlTextWriter buildItems(HtmlTextWriter writer, TermCollection terms)
        {
            //TermSet termSet = navTerms.GetTaxonomyTermSet();

            //if (navTerms.IsNavigationTermSet)
            if (terms.Count > 0)
            {
                Level++;

                foreach (var term in terms)
                {
                    try
                    {
                        var navTerm = NavigationTerm.GetAsResolvedByWeb(term, Site.OpenWeb(),
                                                                        StandardNavigationProviderNames.GlobalNavigationTaxonomyProvider);
                        if (navTerm.ExcludeFromGlobalNavigation)
                        {
                            continue;
                        }

                        buildItem(writer, navTerm);
                    }
                    catch (Exception)
                    {
                    }
                }
                Level--;
            }
            return(writer);
        }
 /// <summary>
 /// Gets a <see cref="NavigationTerm"/> object by the specified unique ID.
 /// </summary>
 /// <param name="termId">Term unique identifier.</param>
 /// <returns>A <see cref="NavigationTerm"/> object.</returns>
 public static NavigationTerm GetNavigationTerm(Guid termId)
 {
     if (SPContext.Current != null && termId != Guid.Empty)
     {
         SPWeb             currentWeb        = SPContext.Current.Web;
         NavigationTermSet navigationTermSet = TaxonomyNavigation.GetTermSetForWeb(currentWeb, StandardNavigationProviderNames.GlobalNavigationTaxonomyProvider, true);
         if (navigationTermSet != null)
         {
             TaxonomySession session = new TaxonomySession(currentWeb, false);
             Term            term    = navigationTermSet.GetTaxonomyTermSet(session).GetTerm(termId);
             if (term != null)
             {
                 using (SPWeb navigationRootWeb = currentWeb.Site.OpenWeb(navigationTermSet.GetResolvedDisplayUrl(null))) {
                     return(NavigationTerm.GetAsResolvedByWeb(term, navigationRootWeb, StandardNavigationProviderNames.GlobalNavigationTaxonomyProvider));
                 }
             }
         }
     }
     return(null);
 }