[英]Copy Presentation Details to new PlaceHolder programmatically Sitecore 7.2
目前,我正在一個頁面上生成特定項目的打印視圖。 因此,這意味着我不需要MainLayout中的所有內容,例如Navigation等。
因此,我創建了一個僅具有占位符的新布局。 讓我們稱之為PrintLayout.aspx:
<sc:placeholder ID="PlPrint" runat="server" key="phPrintOutput"></sc:placeholder>
在后面的代碼中,我有一個方法可以從項目中獲取渲染,但是我被困在想將它們實時復制到phPrintOutput占位符的位置:
public void AddPresentationDetailsToPlaceHolder(Item item)
{
List<RenderingReference> renderings = item.Visualization.GetRenderings(Sitecore.Context.Device, false).ToList();
foreach(RenderingReference r in renderings)
{
// How can I apply the renderings on the fly to my phPrintOutput Placeholder??
}
}
當然,每個子布局保持其當前數據源非常重要。 任何幫助,將不勝感激,謝謝大家
您只需要將控件添加到占位符即可。 為此,請參見下面的代碼:
public void AddPresentationDetailsToPlaceHolder(Item item)
{
List<RenderingReference> renderings = item.Visualization.GetRenderings(Sitecore.Context.Device, false).ToList();
foreach(RenderingReference r in renderings)
{
if(r.RenderingID == new ID("Rendering Id you want to be displayed on layout"))
{
this.PlPrint.Controls.Add(r.GetControl());
}
}
}
這將自動將渲染添加到布局。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.