Placement syntax key could not be found in page editor

I have a repeater in one of the sublayers in Sitecore 6.6. rev 120918. Inside this repeater, I have a placeholder. In ItemDataBoundI assign a key with a GUID to it and using the Nick Wesselman pipeline GetAllowedRendering, I can display the insertion options for this.

The repeater code is very simple:

<asp:Repeater runat="server" ID="rptrTimelineItemsEdit"  OnItemDataBound="rptrTimelineItemsEdit_OnItemDataBound">
  <ItemTemplate>
    <sc:Placeholder ID="scTimelineItemPlaceholder" Key="timelineitemcontent" runat="server" />
  </ItemTemplate>
</asp:Repeater>

Limiting element data is also quite simple:

protected void rptrTimelineItemsEdit_OnItemDataBound(object sender, RepeaterItemEventArgs e)
{
  if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
  {
    Item item = (Item)e.Item.DataItem;

    Placeholder scTimelineItemPlaceholder = (Placeholder)e.Item.FindControl("scTimelineItemPlaceholder");
                scTimelineItemPlaceholder.Key = "timelineitemcontent" + item.ID.ToString().ToLower(); 
  }
}

Everything works up to this point. After I select the subtitle that I want to insert in the placeholder, it throws me into the JS error popup. After checking in the chrome inspector, I see an error:

Could not find the rendering in the HTML loaded from server PlaceholderChromeType.js:601
Sitecore.PageModes.ChromeTypes.Placeholder.Sitecore.PageModes.ChromeTypes.ChromeType.extend._frameLoaded

So - it would seem that in page reloading, sublayer representations occur before the relay is bound, so it cannot find the placeholder key.

google , layoutpageevent:

. . !

+4
3

, , . , . PlaceholderChromeType.js -\sitecore\shell\Applications\Page Modes\ChromeTypes \ dropboxed ( ) https://www.dropbox.com/s/7m99b8jgdz3cgl2/PlaceholderChromeType. . :

protected void R1_ItemDataBound(Object Sender, RepeaterItemEventArgs e)
    {
        var p = e.Item.FindControl("andysplaceholder") as Placeholder;
        p.ID = "Andy" + (e.Item.ItemIndex + 1);
        p.Key = "dynamic" + p.ID;
    }

<asp:repeater id="MyRepeater" runat="server" OnItemDataBound="R1_ItemDataBound">
        <ItemTemplate>        
               <sc:placeholder runat="server" id="andysplaceholder" key="dynamicandysplaceholder" ></sc:placeholder>
        </ItemTemplate>
    </asp:repeater>

oninit-

 protected override void OnInit(EventArgs e)
    {
        base.OnInit(e);

web.config preInit

<setting name="LayoutPageEvent" value="load" />

, _load , .

Sitecore http://mickeyrahman.wordpress.com/2014/05/05/an-ode-to-sitecore-support/#respond

Nick, , , ,

0

, .
, WebControl .
, , "" Placeholder.

, , , , , .
, .

-, : IExpandable
, ( ).
, - LayoutPageEvent, .

EDIT:
, , . , .
Placeholders OnInit ( ), .

, .

0

Dynamic Placeholders IExpandable, , . , , , .

LayoutPageEvent; IExpandable, , .

Expand, . Repeater - , , ASP.Net PlaceHolder.

public class YourSublayout : UserControl, IExpandable
{
    public void Expand()
    {
        var myListOfItems = GetItems()
        foreach (var item in myListOfItems)
        {
            var placeholder = new Placeholder { Key = "key" + item.ID.ToString() };
            container.Controls.Add(placeholder); // add to a control container
            placeholder.Expand();
        }
    }
}

, ( ). , , , Expand , , DataSource , .

0

Source: https://habr.com/ru/post/1532241/


All Articles