Tuesday, 16 July 2013

Creating Page Layouts in SharePoint


A "Page Layout" is a page template that controls how the page looks and exactly which elements (such as lists and libraries) should be present on the page by default when the page has been created using these layouts.



By default SharePoint Provides so many inbuilt layouts like Splash, Blank web part under three content types Article, Redirect and Welcome Page.
We can either create Page Layout from the scratch or customize the copy that comes along with SharePoint.



“PlaceHolderMain” ContentPlaceHolder is the content area reflecting form MasterPage.
You can code all your items inside “PlaceHolderMain”.

Using its PageDisplayMode property, you can make one set of content viewable when the page is in ‘Display’ mode and another set viewable when the page is in ‘Edit’ mode.

When creating Page Layout you need to consider two areas mainly,

·         Display Mode (Page not being Edited)
In ‘Display’ meant the content was visible to anyone who could see the page (as long as the page was in ‘Display’ mode and wasn’t being edited).

FieldName : Refers to the Field name available in Content type

·         Edit Mode (Page being Edited)

In Edit mode, user can edit the content only when the page is edited and it will not visible to the user unless this particular field is coded in Display Section.
For this we have a separate section named Edit mode panel

Example Demonstrating Display and Edit Mode

<asp:Content ContentPlaceholderID="PlaceHolderMain" runat="server">
//Display Mode
<!-- Add field controls here to bind custom metadata viewable and editable in  edit and Published mode.-->
<div>
<SharePointWebControls:TextField FieldName="Title" runat="server"/>
</div>
//Edit Mode
                <PublishingWebControls:editmodepanel runat="server" id="editmodepanel1">
                                <!-- Add field controls here to bind custom metadata viewable and editable in                                   edit mode only.-->
                <SharePointWebControls:TextField FieldName="ArticleByLine" runat="server"/>

                <PublishingWebControls:RichHtmlField ID=”RichHtmlField2″       FieldName=”     PublishingPageContent″ runat=”server”/>

                <SharePointWebControls:datetimefield FieldName="ArticleStartDate" runat="server"                 id="datetimefield3"></SharePointWebControls:datetimefield>               
                </PublishingWebControls:editmodepanel>
 </asp:Content>

In Edit mode panel into your layout, you can place page fields, such as Title or Schedule Dates,   into this panel, allowing you and your editors to add or change this content while they're editing  the page rather than going to the page library to add this information.


In SharePoint 2010 behavior has been changed. Now the EditModePanel control will only shows its contents to users who have permissions to edit the page, regardless of the page’s display mode.
There is another control related to EditModePanel called the AuthoringContainer control. At first glance             it seems pretty similar to EditModePanel except for one key difference: theDisplayAudience property, which can be set to ReadersOnly or AuthorsOnly.


Sample Code that will be useful when creating the page layout in 2010 using SharePoint Designer,
<PublishingWebControls:AuthoringContainer DisplayAudience="ReadersOnly" runat="server">
    <!-- Content you want visible to uses without 'edit' permissions goes here. -->
</PublishingWebControls:AuthoringContainer>

<PublishingWebControls:AuthoringContainer DisplayAudience="AuthorsOnly" runat="server">
    <PublishingWebControls:EditModePanel runat="server" PageDisplayMode="Display">
        <!-- Content you want visible to users with 'edit' permissions and in display mode goes here -->
    </PublishingWebControls:EditModePanel>

    <PublishingWebControls:EditModePanel runat="server" PageDisplayMode="Edit">
        <!-- Content you want visible to users *with* 'edit' permissions and in edit mode goes here -->
    </PublishingWebControls:EditModePanel>
</PublishingWebControls:AuthoringContainer>


No comments:

Post a Comment