コード例 #1
0
        public static HtmlString DynamicPlaceholder(this SitecoreHelper helper, string placeholderName, ID placeholderSuffix)
        {
            Assert.ArgumentNotNull(placeholderName, nameof(placeholderName));

            helper.CurrentRendering.Parameters[GetUniqueIdKeyWithinRendering.RenderingParameterKey] = placeholderSuffix.ToString();

            return(helper.DynamicPlaceholder(new DynamicPlaceholderDefinition(placeholderName)));
        }
コード例 #2
0
        private static HtmlTag ApplyDynamicPlaceholderSyntax(SitecoreHelper helper, HtmlTag tag)
        {
            var match = DynamicPlaceholderRegex.Match(tag.Text);

            if (match.Success)
            {
                var placeholderKey = match.Groups["placeholderKey"].Value;
                var parameters     = ParseParameters(match.Groups["parameters"].Value);
                var count          = MainUtil.GetInt(parameters["count"], 1);
                var maxCount       = MainUtil.GetInt(parameters["maxCount"], 0);
                var seed           = MainUtil.GetInt(parameters["seed"], 0);
                var placeholder    = helper.DynamicPlaceholder(placeholderKey, count, maxCount, seed).ToString();
                tag.Text = DynamicPlaceholderRegex.Replace(tag.Text, placeholder);
            }

            return(tag);
        }
コード例 #3
0
        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
            });
        }
コード例 #4
0
 public static HtmlString DynamicPlaceholder(this SitecoreHelper helper, string placeholderName, string className, int count)
 {
     return(helper.DynamicPlaceholder(placeholderName, CreateColumnWrapper(className), count: count));
 }
コード例 #5
0
 public static HtmlString DynamicPlaceholder(this SitecoreHelper helper, string placeholderName, bool useStaticPlaceholderNames = false)
 {
     return(useStaticPlaceholderNames ? helper.Placeholder(placeholderName) : helper.DynamicPlaceholder(placeholderName));
 }
コード例 #6
0
 public static HtmlString DynamicPlaceholder(this SitecoreHelper helper, string placeholderName)
 {
     return(helper.DynamicPlaceholder(placeholderName, false));
 }