/// <summary> /// Creates an instance of the <see cref="SeoMetaListItem"/> with the specified managed navigation node. /// </summary> /// <param name="contextWeb"></param> /// <param name="term"></param> public SeoMetaNavigationTerm(SPWeb contextWeb, NavigationTerm term) { TaxonomySession session = new TaxonomySession(contextWeb, false); this.term = term.GetTaxonomyTerm(session); }
// Primary BuildItem // Outputs a single menu item or menu item + sub-tree //public void buildItem(HtmlTextWriter writer, Term term) public void buildItem(HtmlTextWriter writer, NavigationTerm navTerm) { var temp = ""; var term = navTerm.GetTaxonomyTerm(); // Check permissions?? //if (!term.DoesUserHavePermissions()) //{ //return; //} // Instantiate current item CurrentItem = new MenuItem(); CurrentItem.Term = new CurrentTerm(term, navTerm); CurrentItem.TermSet = CTermSet; //temp = htmlBeforeLi if (term.CustomProperties.TryGetValue("htmlBeforeLi", out temp)) { writer.Write(temp); } // MegaMenu classes: dropdown-wide, dropdown-short, dropdown-full, dropdown-onhover, dropdown-menu, dropdown-carousel, dropdwn-grid if (term.CustomProperties.TryGetValue("itemClasses", out temp)) { CurrentItem.AddClass(temp); } if (term.CustomProperties.TryGetValue("columns", out temp)) { CurrentItem.AddClass("columns"); CurrentItem.AddClass("columns-" + temp); } if (term.CustomProperties.TryGetValue("iconOnly", out temp)) { CurrentItem.AddClass(temp); CurrentItem.AddClass("icon-only"); CurrentItem.AddClass("image-icon-only"); } else if (term.CustomProperties.TryGetValue("imageOnly", out temp)) { CurrentItem.AddClass(temp); CurrentItem.AddClass("image-only"); CurrentItem.AddClass("image-icon-only"); } // Add level class CurrentItem.Level = Level; if (HasChildren(term)) { CurrentItem.AddClass("dropdown"); if (term.CustomProperties.ContainsKey("megamenu")) { CurrentItem.AddClass("imegamenu"); CurrentItem.AddClass("dropdown-short"); } ShowChildren = false; if (!term.CustomProperties.ContainsKey("showChildren")) { if (1 < Level) { CurrentItem.AddClass("dropdown-right-onhover"); CurrentItem.AddClass("no-fix"); } else { CurrentItem.AddClass("dropdown-onhover"); } } else { ShowChildren = true; CurrentItem.AddClass("dropdown-onhover"); CurrentItem.AddClass("dropdown-show"); } // If dropdown, add attributes //writer.AddAttribute("data-toggle", "dropdown"); // @todo Add style attribute if (term.CustomProperties.TryGetValue("style", out temp)) { writer.AddAttribute(HtmlTextWriterAttribute.Style, temp); } // @todo Add data tags, entered name: data-name value: * // Can I get all properties that begin with a string?? //if (term.CustomProperties.TryGetValue("data", out temp)) { //writer.AddAttribute("", currentItem.GetStyles()); //} } writer.AddAttribute(HtmlTextWriterAttribute.Class, CurrentItem.GetClasses()); writer.RenderBeginTag(HtmlTextWriterTag.Li); if (term.CustomProperties.TryGetValue("htmlBefore", out temp)) { writer.Write(temp); } //if (this.hasChildren(term) && term.CustomProperties.ContainsKey("showChildren")) if (HasChildren(term)) { RenderDropDown(writer, term, navTerm); } else { RenderLink(writer, term, navTerm); } //writer.Write(this.getValue(term)); //writer.Write(this.getDescription(term)); if (term.CustomProperties.TryGetValue("htmlAfter", out temp)) { writer.Write(temp); } // Now writer.RenderEndTag(); // </li> if (term.CustomProperties.TryGetValue("htmlAfterLi", out temp)) { writer.Write(temp); } }