﻿using System.Linq;
using Sitecore.Mvc.Helpers;
using Sitecore.Mvc.Presentation;
using System.Collections.Generic;
using System.Web;

namespace DynamicPlaceholders.Mvc.Extensions
{
	public static class SitecoreHelperExtensions
	{
		public static List<string> DynamicPlaceholders = new List<string>();

		public static HtmlString DynamicPlaceholder(this SitecoreHelper helper, string placeholderName)
		{
			var placeholder = string.Format("{0}_{1}", placeholderName, RenderingContext.Current.Rendering.UniqueId);
			var count = 0;

			if ((count = DynamicPlaceholders.Count(dp => dp.StartsWith(placeholder))) > 0)
			{
				placeholder = string.Format("{0}_{1}", placeholder, count);

				DynamicPlaceholders.Add(placeholder);
			}

			return helper.Placeholder(placeholder);
		}
	}
}

﻿using Sitecore.Mvc.Helpers;
using Sitecore.Mvc.Presentation;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace DynamicPlaceholders.Mvc.Extensions
{
	public static class SitecoreHelperExtensions
	{
		public static HtmlString DynamicPlaceholder(this SitecoreHelper helper, string placeholderName)
		{
			var currentRenderingId = RenderingContext.Current.Rendering.UniqueId;

			return helper.Placeholder(string.Format("{0}_{1}", placeholderName, currentRenderingId));
		}
	}
}

Revert "Added ability to have more than one dynamic placeholder in the same rendering"
Revert "Added ability to have more than one dynamic placeholder in the same rendering"

This reverts commit c69f12278522dc585254dbeac3176c8d790c9e9c.
