Skip to content

SitecoreExtension for adding DynamicKeyPlaceholders allowing for multiple spots with placeholders on one page.

Notifications You must be signed in to change notification settings

netzkern/SitecoreExtension-DynamicKeyPlaceholder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SitecoreExtension-DynamicKeyPlaceholder

SitecoreExtension for adding DynamicKeyPlaceholders allowing for a spot with placeholder to be added multiple times to a page.

Appends the rendering Unique Id to the Placeholder id for allowing a unique reference for the page renderings to attach on, default implementation only allows for a single Placeholder ID to be present on a page at one time. The extension is hidden to the ediors.

Based on prior work that turned out to be the same solution that Nick Wesselman blogged about at http://www.techphoria414.com/Blog/2012/May/Sitecore_Page_Editor_Unleashed

Now available on nuget and github.

1508 / Design in Love with Technology / http://1508.dk

Requirements

  • Sitecore 6.x

Installation

Install via nuget

  PM> Install-Package SitecoreExtension.DynamicKeyPlaceholder

Use the Control DynamicKeyPlaceholder instead of a Sitecore Placeholder control.

To get DynamicKeyPlaceholders to work inside of ListViews, you also have to manually change /sitecore/shell/Applications/Page Modes/ChromeTypes/PlaceholderChromeType.js on line 34 from:

addControlResponse: function(id, openProperties, ds) {                       
    var options = Sitecore.PageModes.ChromeTypes.Placeholder.getDefaultAjaxOptions("insert");
    options.context = this;    
    options.data.rendering = id;
    options.data.placeholderKey = this.placeholderKey();
    [...]           

to:

addControlResponse: function (id, openProperties, ds) {
    var phkey = this.placeholderKey();
    var options = Sitecore.PageModes.ChromeTypes.Placeholder.getDefaultAjaxOptions("insert");
    options.context = this;
    options.data.rendering = id;
    if (phkey.match(/{{.*}}/ig)) {
        options.data.placeholderKey = phkey.substring(phkey.lastIndexOf("/"));
    } else {
        options.data.placeholderKey = phkey;
    }
    [...]

Example of use

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SpotsContainer.ascx.cs" Inherits="Web.UI.SpotsContainer" %>
<%@ Register TagPrefix="sce" Namespace="SitecoreExtension.DynamicKeyPlaceholder.Controls" Assembly="SitecoreExtension.DynamicKeyPlaceholder" %>
<div class="container container-wide">
    <div class="container-inner">
        <div class="spots">
            <sce:DynamicKeyPlaceholder runat="server" ID="SpotsPlaceholder" Key="SpotsPlaceholder" editable="true" />
        </div>
    </div>
</div>

Notice

Once content is added into the dynamic placeholders the rendering is bound the the placeholderid combined with the unique rendering id, meaning that removing a spot with the dynamic placeholder and adding it again will create a new unique id and therefore will leave the other renderings orphans in the layout information and the user must re-add the renderings. This is sound and expected behavior :)

About

SitecoreExtension for adding DynamicKeyPlaceholders allowing for multiple spots with placeholders on one page.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published