I use Dynamic Placeholders in Sitecore 7 as described in the articles
It works correctly, so I can add the same rendering to the layout and the rendering will go to the corresponding dynamic Placeholder. However, when I click to add rendering to a dynamic placeholder, placeholder settings are not used.
What I expect should be triggered by allowed visualizations that can be hosted on the Dynamic Placeholder. Instead, the render / layout tree is manually presented to select the rendered content editors to add forbidden visualizations to the placeholder.
I debugged the code, and the correct Placeholder parameter was found for the Dynamic Placeholder parameter, and the list of allowed Renderings is retrieved, despite the fact that it is set to args, the list is not presented to the user. See code below.
public class GetDynamicKeyAllowedRenderings : GetAllowedRenderings
{
public const string DynamicKeyRegex = @"(.+){[\d\w]{8}\-([\d\w]{4}\-){3}[\d\w]{12}}";
public new void Process(GetPlaceholderRenderingsArgs args)
{
Assert.IsNotNull(args, "args");
string placeholderKey = args.PlaceholderKey;
var regex = new Regex(DynamicKeyRegex);
Match match = regex.Match(placeholderKey);
if (match.Success && match.Groups.Count > 0)
{
placeholderKey = match.Groups[1].Value;
}
else
{
return;
}
Item placeholderItem = null;
if (ID.IsNullOrEmpty(args.DeviceId))
{
placeholderItem = Client.Page.GetPlaceholderItem(placeholderKey, args.ContentDatabase,
args.LayoutDefinition);
}
else
{
using (new DeviceSwitcher(args.DeviceId, args.ContentDatabase))
{
placeholderItem = Client.Page.GetPlaceholderItem(placeholderKey, args.ContentDatabase,
args.LayoutDefinition);
}
}
List<Item> collection = null;
if (placeholderItem != null)
{
bool allowedControlsSpecified;
args.HasPlaceholderSettings = true;
collection = this.GetRenderings(placeholderItem, out allowedControlsSpecified);
if (allowedControlsSpecified)
{
args.CustomData["allowedControlsSpecified"] = true;
}
}
if (collection != null)
{
if (args.PlaceholderRenderings == null)
{
args.PlaceholderRenderings = new List<Item>();
}
args.PlaceholderRenderings.AddRange(collection);
}
}
}
How this code was developed for Sitecore 6.5 / 6.6. I wonder if Sitecore 7.0 added a change to the second half of the code.
source
share