This article will show you how to correctly inherit content of an editable region on a sub page, when using ASPX page templates.
In previous versions of Kentico CMS, the InheritContent property allowed you to inherit content when using the Portal engine, as well as ASPX templates. However, using the InheritContent property in ASPX templates didn’t always work correctly, since the tree structure in ASPX page templates was unknown.  The code snipped below allows you to work around this problem:

Place this code into the ASPX code of your page template, where you want to have inherited content:

<cms:CMSEditableRegion runat="server" ID="TopText" RegionType="HtmlEditor" RegionTitle="Top content text" InheritContent="true" />
<asp:PlaceHolder runat="server" ID="plcContent">
<asp:Literal ID="ltlRegion" runat="server" Visible="false"/>
</asp:PlaceHolder>

Then, in the code behind of the template, use this code to load the content to the label:

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

           // If it is some child document (not root)
            if (CMS.CMSHelper.CMSContext.CurrentPageInfo.NodeLevel > 0)
            {
                CMS.PortalEngine.PageInfo parentpi = CMS.PortalEngine.PageInfoProvider.GetPageInfo(CMS.CMSHelper.CMSContext.CurrentSiteName, "", CMS.CMSHelper.CMSContext.CurrentDocumentCulture.CultureCode, "", CMS.CMSHelper.CMSContext.CurrentPageInfo.NodeParentId, false);
                // Show label for editable region content
                this.ltlRegion.Visible = true;
                // Hide editale region control
                this.TopText.Visible = false;
                this.ltlRegion.Text = CMS.GlobalHelper.ValidationHelper.GetString(parentpi.EditableRegions[TopText.ID.ToLower()], "");
                CMS.ExtendedControls.ControlsHelper.ResolveDynamicControls(this.plcContent);
            }
       
    }
-jo-


See also:

Applies to: Kentico CMS 6.x
Created on 5/14/2012 11:08:37 AM in Content Management
 
0 ratings
Sitemap | Content Management System | E-commerce Software | Social Networking Software | Intranet | Online Marketing Solution | Copyright © 2004-2013 Kentico Software | Powered by Kentico CMS