Exemplo n.º 1
0
 public static HtmlString DynamicPlaceholder(this SitecoreHelper helper, string placeholderName, bool useStaticPlaceholderNames = false)
 {
     if (useStaticPlaceholderNames)
     {
         return(helper.Placeholder(placeholderName));
     }
     return(DynamicPlaceholderExtension.DynamicPlaceholder(helper, placeholderName));
 }
        public static HtmlString DynamicPlaceholder(this SitecoreHelper helper, string dynamicKey)
        {
            Guid currentRenderingId = RenderingContext.Current.Rendering.UniqueId;

            if (currentRenderingId != Guid.Empty)
            {
                return(helper.Placeholder(String.Format("{0}_{1}", dynamicKey, currentRenderingId)));
            }

            if (Sitecore.Context.PageMode.IsExperienceEditorEditing)
            {
                return(new HtmlString(string.Format(@"<div data-container-title=""{0}"">{1}</div>",
                                                    dynamicKey,
                                                    helper.Placeholder(dynamicKey).ToHtmlString())));
            }
            else
            {
                return(helper.Placeholder(dynamicKey));
            }
        }
        private static HtmlTag ApplyStaticPlaceholderSyntax(SitecoreHelper helper, HtmlTag tag)
        {
            var match = StaticPlaceholderRegex.Match(tag.Text);

            if (match.Success)
            {
                var placeholderKey = match.Groups["placeholderKey"].Value;
                var placeholder    = helper.Placeholder(placeholderKey).ToString();
                tag.Text = StaticPlaceholderRegex.Replace(tag.Text, placeholder);
            }

            return(tag);
        }
Exemplo n.º 4
0
        private HtmlString RenderPlaceholder(Item contextItem, ViewPart viewPart)
        {
            var phdName = viewPart["Name"];

            if (!string.IsNullOrEmpty(phdName))
            {
                var phHtml = _scHelper.Placeholder(phdName);

                if (!string.IsNullOrEmpty(viewPart.TagWrapper))
                    phHtml = phHtml.WrapWithTag(viewPart.TagWrapper);

                return phHtml;
            }

            return new HtmlString(string.Empty);
        }
 public static HtmlString DynamicPlaceholder(this SitecoreHelper helper, string placeholderName, bool useStaticPlaceholderNames = false)
 {
     return(useStaticPlaceholderNames ? helper.Placeholder(placeholderName) : helper.DynamicPlaceholder(placeholderName));
 }
        public static HtmlString DynamicPlaceholder(this SitecoreHelper helper, string placeholderName)
        {
            var placeholder = PlaceholdersContext.Add(placeholderName, RenderingContext.Current.Rendering.UniqueId);

            return(helper.Placeholder(placeholder));
        }
        public static HtmlString DynamicPlaceholder(this SitecoreHelper helper, string key)
        {
            var id = helper.CurrentRendering.UniqueId;

            return(helper.Placeholder(DynamicPlaceholderKeyProvider.GetKey(key, id)));
        }
 public static HtmlString DynamicPlaceholder(this SitecoreHelper helper, string dynamicKey)
 {
     return(helper.Placeholder($"{dynamicKey}_{RenderingContext.Current.Rendering.UniqueId}"));
 }
 public static HtmlString DynamicPlaceholder(this SitecoreHelper sitecoreHelper, string placeholderName, bool useStaticPlaceholderNames)
 {
     return(useStaticPlaceholderNames ? sitecoreHelper.Placeholder(placeholderName) : DynamicPlaceholder(sitecoreHelper, placeholderName));
 }
        public static ReactPlaceholder GetPlaceholder(string placeholderName, HtmlHelper htmlHelper, bool isDynamic)
        {
            var scHelper    = new SitecoreHelper(htmlHelper);
            var placeholder = isDynamic ? scHelper.DynamicPlaceholder(placeholderName) : scHelper.Placeholder(placeholderName);

            Regex regex = new Regex(@"key='(.[^']+)'");;

            if (!Sitecore.Context.PageMode.IsExperienceEditor)
            {
                regex = new Regex(@"id=""(.[^""]+)""");
            }
            Match  match = regex.Match(placeholder.ToString());
            string key   = match.Groups[1].Value;

            //todo: find out if we can get the original placeholder keys via Sitecore.Context.Page.Renderings...

            return(new ReactPlaceholder()
            {
                PlaceholderKey = key, Placeholder = placeholder.ToString(), IsDynamic = isDynamic
            });
        }
        public static IHtmlString TrueDynamicPlaceholder(this SitecoreHelper sitecoreHelper, string placeholderName)
        {
            Rendering currentRendering = RenderingContext.Current.Rendering;

            return(sitecoreHelper.Placeholder(string.Format("{0}|{1}", placeholderName, currentRendering.UniqueId.ToString())));
        }