private void rptLinks_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.IsItem()) { NavigationLinkItem item = (NavigationLinkItem)e.Item.DataItem; FieldRenderer frLink = e.FindControlAs <FieldRenderer>("frLink"); frLink.Item = item; if (item.Link.Field != null) { // Handle initial menu choice if (e.Item.ItemIndex == 0) { litInitialMenuChoice.Text = item.Link.Field.Text; } // Selected state Item navItem = Sitecore.Context.Item; while (navItem != null) { if (item.Link.Field.TargetID == navItem.ID) { frLink.Parameters = "class=selected"; break; } navItem = navItem.Parent; } } } }
protected string GetSelectedState(NavigationLinkItem item, string selectedCss) { return((_levelOne != null && item.Link.Field.TargetItem != null && item.Link.Field.TargetItem.ID == _levelOne.ID) ? selectedCss : string.Empty); }
protected void rptFooterNav_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.IsItem()) { NavigationLinkItem navItem = e.Item.DataItem as NavigationLinkItem; if (navItem != null) { FieldRenderer frLink = e.FindControlAs <FieldRenderer>("frLink"); if (frLink != null) { frLink.Item = navItem; } } } }
protected void rptFilter_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.IsItem()) { NavigationLinkItem navItem = e.Item.DataItem as NavigationLinkItem; FieldRenderer frLink = e.FindControlAs <FieldRenderer>("frLink"); if (frLink != null) { frLink.Item = navItem; } LinkField lf = navItem.Link.Field; if (Sitecore.Context.Item.ID == lf.TargetItem.ID) { bool hasMatch = false; // Selected state of filter item if (string.IsNullOrEmpty(lf.QueryString)) { hasMatch = true; } else { // Handle featured //string assembledUrl = String.Format("{0}?{1}", lf.TargetItem.GetUrl(), lf.QueryString); //hasMatch = Request.Url.PathAndQuery.StartsWith(assembledUrl); hasMatch = Request.Url.PathAndQuery.Contains(lf.QueryString); } if (hasMatch) { litSelectedMenu.Text = lf.Text; } } } }
protected void rptEventCarousel_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.IsItem()) { NavigationLinkItem navItem = (NavigationLinkItem)e.Item.DataItem; Link scLink = e.FindControlAs <Link>("scLink"); Literal litDevStart = e.FindControlAs <Literal>("litDevStart"); Literal litStartUL = e.FindControlAs <Literal>("litStartUL"); Literal litEndUL = e.FindControlAs <Literal>("litEndUL"); Literal litDivEnd = e.FindControlAs <Literal>("litDivEnd"); HyperLink hlLink = e.FindControlAs <HyperLink>("hlLink"); HtmlGenericControl divIcon = e.FindControlAs <HtmlGenericControl>("divIcon"); if (litDevStart != null && litStartUL != null && litEndUL != null && litDivEnd != null) { int cindex = e.Item.ItemIndex + 1; if (cindex == 1) { litDevStart.Visible = litStartUL.Visible = true; } if ((cindex) % 2 == 0 && (cindex) != 1) { litEndUL.Visible = true; } //if ((cindex) % 3 == 0 && (cindex) != 1) { // litStartUL.Visible = true; //} //if ((cindex) == 3) { // litStartUL.Visible = true; // nextUlStart = cindex + 4; //} //if (cindex == nextUlStart) { // litStartUL.Visible = true; //} if ((cindex) % 2 == 1 && (cindex) != 1) { litStartUL.Visible = true; } if ((cindex) % 4 == 0 && (cindex) != 1) { litDivEnd.Visible = true; } //if ((cindex) % 5 == 0 && (cindex) != 1) { // litDevStart.Visible = true; // litStartUL.Visible = true; //} if ((cindex) % 4 == 1 && (cindex) != 1) { litDevStart.Visible = true; //litStartUL.Visible = true; } //if (rptEventCarousel.Items.Count == cindex) { if (toolsCount == cindex) { litEndUL.Visible = true; litDivEnd.Visible = true; } //if ((toolsCount == cindex) && ((cindex) % 2 == 1)) { // //LI PADDING ADD // liItem.Attributes.Add("style", "padding-right:25px;"); //} } if (divIcon != null && navItem.Image.MediaItem != null) { //divIcon.Attributes.Add("style", "background: url(" + objNavItem.Image.MediaUrl + ") no-repeat scroll 0 0 / 100px 100px rgba(0, 0, 0, 0)"); divIcon.Attributes.Add("style", "background-image: url(" + navItem.Image.MediaUrl + ");background-repeat:no-repeat;"); } if (scLink != null) { scLink.Item = navItem; } } }