From f6927910b4f54322748024b834ae006e2ff9c715 Mon Sep 17 00:00:00 2001 From: Vicent Galiana Date: Thu, 23 Apr 2020 11:39:02 +0200 Subject: [PATCH 1/2] Improving the generation of the parent ID from the placeholder key, supporting multiple placeholder in the samme component and using the uniqueKey. Solving issue #7 --- Source/DynamicPlaceholders/Events/DynamicPlaceholder.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/DynamicPlaceholders/Events/DynamicPlaceholder.cs b/Source/DynamicPlaceholders/Events/DynamicPlaceholder.cs index 441772f..00b94cf 100644 --- a/Source/DynamicPlaceholders/Events/DynamicPlaceholder.cs +++ b/Source/DynamicPlaceholders/Events/DynamicPlaceholder.cs @@ -30,7 +30,7 @@ public void OnItemSaved(object sender, EventArgs args) if (match.Success && match.Groups.Count > 0) { - var parentRenderingId = "{" + key.Substring(key.Length - 36, 36).ToUpper() + "}"; + var parentRenderingId = "{" + key.Substring(key.LastIndexOf("_") - 36, 36).ToUpper() + "}"; if (renderingReferences.All(r => r.UniqueId.ToUpper() != parentRenderingId)) { From c3e2aec23d07f5a383e19f942082733f0b65ed5c Mon Sep 17 00:00:00 2001 From: Vicent Galiana Date: Thu, 23 Apr 2020 12:36:15 +0200 Subject: [PATCH 2/2] Improving handling of single and multiple placeholders int he same component. Issue #7, PR #8 --- Source/DynamicPlaceholders/Events/DynamicPlaceholder.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Source/DynamicPlaceholders/Events/DynamicPlaceholder.cs b/Source/DynamicPlaceholders/Events/DynamicPlaceholder.cs index 00b94cf..5065bcd 100644 --- a/Source/DynamicPlaceholders/Events/DynamicPlaceholder.cs +++ b/Source/DynamicPlaceholders/Events/DynamicPlaceholder.cs @@ -30,7 +30,10 @@ public void OnItemSaved(object sender, EventArgs args) if (match.Success && match.Groups.Count > 0) { - var parentRenderingId = "{" + key.Substring(key.LastIndexOf("_") - 36, 36).ToUpper() + "}"; + int startingposition = key.Length; + if (key.Count(c => c == '_') > 1) + startingposition = key.LastIndexOf('_'); + var parentRenderingId = "{" + key.Substring(startingposition - 36, 36).ToUpper() + "}"; if (renderingReferences.All(r => r.UniqueId.ToUpper() != parentRenderingId)) {