public static void AttachToLinkField(this Link link, IHyperlinkField field) { var item = (FieldType)field; link.Item = item.InnerField.Item; link.Field = item.InnerField.ID.ToString(); }
/// <summary> /// Renders a Synthesis Hyperlink Field to a HtmlTextWriter and configures parameters of the field renderer /// </summary> public static void RenderLinkField(this HtmlTextWriter writer, IHyperlinkField linkField, Action<Link> parameters) { if (linkField.HasValue || Sitecore.Context.PageMode.IsPageEditor) { var link = new Link(); link.AttachToLinkField(linkField); parameters(link); link.RenderControl(writer); } }
/// <summary> /// Renders a Synthesis Hyperlink Field to a HtmlTextWriter and configures parameters of the field renderer /// </summary> public static void RenderLinkField(this HtmlTextWriter writer, IHyperlinkField linkField, Action <Link> parameters) { if (linkField.HasValue || Sitecore.Context.PageMode.IsExperienceEditor) { var link = new Link(); link.AttachToLinkField(linkField); parameters(link); link.RenderControl(writer); } }
public static IDisposable RenderWithBody <T>(this IHyperlinkField field, HtmlHelper <T> helper, string cssClass = null) { object parameters = new { haschildren = true }; if (cssClass != null) { parameters = new { haschildren = true, @class = cssClass }; } return(new TagRenderingContext <T>(helper, (FieldType)field, parameters)); }
public static IHtmlString Render(this IHyperlinkField field, Action <Link> parameters) { if (field.HasValue || Sitecore.Context.PageMode.IsExperienceEditor) { var link = new Link(); link.AttachToLinkField(field); parameters(link); return(new MvcHtmlString(link.RenderAsText())); } return(new MvcHtmlString(string.Empty)); }
public static IHtmlString Render(this IHyperlinkField field, string linkText = null, string cssClass = null, bool editable = true) { return(Render(field, x => { if (linkText != null) { x.Text = linkText; } if (cssClass != null) { x.CssClass = cssClass; } if (!editable) { x.DisableWebEditing = true; } })); }
/// <summary> /// Renders a Synthesis Hyperlink Field to a HtmlTextWriter. /// </summary> public static void RenderLinkField(this HtmlTextWriter writer, IHyperlinkField linkField) { RenderLinkField(writer, linkField, x => { }); }
/// <summary> /// Returns a list of pages to include in the specified page's breadcrumb. /// </summary> //public IEnumerable<IBasePageItem> GetBreadcrumbForPage(IBasePageItem page) //{ // // Create the collection. // var pages = new List<IBasePageItem>(); // // The current page is always included unless it has been set not to. // if (page.DisplayPageinBreadcrumb.Value) // pages.Add(page); // // Loop through the current page's ancestors - in reverse. // foreach (var ancestor in page.Axes.GetAncestors().Reverse()) // { // // If we reach the site root, stop. // if (ancestor.TemplateId == WebsiteFolder.ItemTemplateId) break; // // If the ancestor isn't a page, skip it. // var ancestorPage = ancestor as IBasePageItem; // if (ancestorPage == null) continue; // // If the ancestor is supposed to be displayed in the breadcrumb, add it to the list. // if (ancestorPage.DisplayPageinBreadcrumb.Value) // pages.Add(ancestorPage); // } // // Reverse the list of pages so that the current page is last. // pages.Reverse(); // // Return. // return pages; //} public string GetUrlFromLinkField(IHyperlinkField linkField) { return linkField == null ? string.Empty : GetUrlFromLinkField(linkField.ToLinkField()); }