public static HtmlString DynamicPlaceholder(this Sitecore.Mvc.Helpers.SitecoreHelper helper, string dynamicKey) { var currentRenderingId = RenderingContext.Current.Rendering.UniqueId; //return helper.Placeholder(string.Format("{0}_dph_{1}", dynamicKey, currentRenderingId)); return(helper.Placeholder(dynamicKey)); }
public static HtmlString TagField(this Sitecore.Mvc.Helpers.SitecoreHelper sitecoreHelper, string fieldNameOrId, string htmlElement, bool disableWebEdit = false, Sitecore.Collections.SafeDictionary <string> parameters = null) { var item = Sitecore.Mvc.Presentation.RenderingContext.Current.ContextItem; if (item == null || string.IsNullOrEmpty(item[fieldNameOrId])) { return(new HtmlString(string.Empty)); } var value = sitecoreHelper.RenderField(fieldNameOrId, disableWebEdit, parameters).ToString(); return(new HtmlString(string.Format("<{0}>{1}</{0}>", htmlElement, value))); }
/// <summary> /// Returns the visitor identification snippet if needed /// </summary> /// <param name="sitecoreHelper">The sitecore helper.</param> /// <returns> /// HtmlString with the identification snippet /// </returns> public static HtmlString AnalyticsVisitorIdentification(this Sitecore.Mvc.Helpers.SitecoreHelper sitecoreHelper) { if (Context.Diagnostics.Tracing || Context.Diagnostics.Profiling) { return(new HtmlString("<!-- Visitor identification is disabled because debugging is active. -->")); } if (!Tracker.IsActive || Tracker.Current.Contact.System.Classification != 925) { return(MvcHtmlString.Empty); } return(new HtmlString("<link href=\"/layouts/System/VisitorIdentification.aspx\" rel=\"stylesheet\" type=\"text/css\" />")); }
public static HtmlString RenderField(this Sitecore.Mvc.Helpers.SitecoreHelper sitecoreHelper, string fieldNameOrId, bool disableWebEdit = false, Sitecore.Collections.SafeDictionary <string> parameters = null) { if (parameters == null) { parameters = new Sitecore.Collections.SafeDictionary <string>(); } return(sitecoreHelper.Field(fieldNameOrId, new { DisableWebEdit = disableWebEdit, Parameters = parameters })); }
public static HtmlString RenderDate(this Sitecore.Mvc.Helpers.SitecoreHelper sitecoreHelper, string fieldNameOrId, string format = "D", bool disableWebEdit = false, bool setCulture = true, Sitecore.Collections.SafeDictionary <string> parameters = null) { if (setCulture) { Thread.CurrentThread.CurrentUICulture = new CultureInfo(Sitecore.Context.Language.Name); Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Sitecore.Context.Language.Name); } if (parameters == null) { parameters = new Sitecore.Collections.SafeDictionary <string>(); } parameters["format"] = format; return(RenderField(sitecoreHelper, fieldNameOrId, disableWebEdit, parameters)); }
public static string GetMediaUrl(this Sitecore.Mvc.Helpers.SitecoreHelper sitecoreHelper, string fieldName, Item item) { ImageField imageField = item.Fields[fieldName]; return(Sitecore.Resources.Media.MediaManager.GetMediaUrl(imageField.MediaItem)); }
public static string GetMediaUrl(this Sitecore.Mvc.Helpers.SitecoreHelper sitecoreHelper, string fieldName) { return(GetMediaUrl(sitecoreHelper, fieldName, sitecoreHelper.CurrentItem)); }
public static HtmlString DynamicPlaceholder(this Sitecore.Mvc.Helpers.SitecoreHelper helper, string dynamicKey) { return(helper.Placeholder($"{dynamicKey}_{RenderingContext.Current.Rendering.UniqueId}")); }
public override void InitHelpers() { base.InitHelpers(); this.SitecoreHelper = this.Html.Sitecore(); }
public static HtmlString TagField(this Sitecore.Mvc.Helpers.SitecoreHelper sitecoreHelper, Sitecore.Data.ID fieldId, string htmlElement, bool disableWebEdit = false, Sitecore.Collections.SafeDictionary <string> parameters = null) { return(TagField(sitecoreHelper, fieldId.ToString(), htmlElement, disableWebEdit, parameters)); }
public static HtmlString RenderDate(this Sitecore.Mvc.Helpers.SitecoreHelper sitecoreHelper, Sitecore.Data.ID fieldId, string format = "D", bool disableWebEdit = false, bool setCulture = true, Sitecore.Collections.SafeDictionary <string> parameters = null) { return(RenderDate(sitecoreHelper, fieldId.ToString(), format, disableWebEdit, setCulture, parameters)); }