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.
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.
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).
‘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.
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.-->
edit mode only.-->
<SharePointWebControls:TextField FieldName="ArticleByLine" runat="server"/>
<PublishingWebControls:RichHtmlField ID=”RichHtmlField2″ FieldName=”
PublishingPageContent″ runat=”server”/>
PublishingPageContent″ runat=”server”/>
<SharePointWebControls:datetimefield FieldName="ArticleStartDate" runat="server"
id="datetimefield3"></SharePointWebControls:datetimefield>
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.
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.
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>
Monday, 15 July 2013
Displaying Custom Fields in Content Query Web Part
The Content Query Web Part (CQWP) allows you to display data from a list anywhere within a Site Collection..
However, by default the CQWP only displays the freaking ‘Title’ field, if you want to display
all the other field in the list you have to do all the below modifications,
In the Tool Pane, expand Presentation and experiment with the drop down options under Styles.
Select Apply to see the changes. These are default styles available in MOSS 2007.
Select Apply to see the changes. These are default styles available in MOSS 2007.
All these styles will be available in a single file named “ITEMSTYLE.XSL”. This file is
available under Style Library/XSL Style Sheets/.You can use SharePoint designer to
customize this file.
available under Style Library/XSL Style Sheets/.You can use SharePoint designer to
customize this file.
Take a minute to look at the file. Every time you see "<xsl:template..." that is the start of a new Item Style. There is one for each of the out-of-the-box Item Styles that show up in the Styles drop down in the Web Part Tool Pane. For every custom Item Style that is needed, a new< xsl:template> </xsl:template> block will have to be created.
1) Scroll down to the bottom of the file. Copy the last xsl:template code block and paste it above the closing xsl:stylesheet tag.
2) Change the name and match properties in the Template tag to a unique name of your choice:
Format:
<xsl:template name="NewsItemStyle" match="Row[@Style='NewsItemStyle']" mode="itemstyle">
3) Before we style any content, we need to have the web part pull in the content we want to display. Some content is already pulled in by default, such as Title. For anything else that is not pulled by default, we need to tell the web part to get those fields. Steps to do that
A. In the Content Query Web Part you have inserted on the page, click edit, and then click Export.
B. In the File Download dialog box, click Save. In the Save As dialog box, type a name and location for the .webpart file. Click Save in the Save As dialog box to save the file.
C. Open the saved file and search for “CommonViewFields” text, you can able to see tags like this,
<property name="CommonViewFields" type="string"></property>
D. Add the list column name and along with column type you need in the new style.
And the Field type can be notified below,
E. After adding the necessary fields inside the tag, save the file.
F. Finally import this file as web part in moss2007.(Delete the previously added content query web part)
4) Now customize the ITEMSTYLE.XSL file with necessary UI design format,
Example:
<div class="description">
<xsl:value-of select="@Rollup" />
<xsl:value-of select="@Rollup" />
<xsl:value-of select="@Body" />
</div>
</div>
Note:
Rollup and Body are the fields we added in the .WEBPART file.
5) Complete code for NewsItemStyle has been written here.
<xsl:template name="NewsItemStyle" match="Row[@Style='NewsItemStyle']" mode="itemstyle">
<xsl:variable name="SafeLinkUrl">
<xsl:call-template name="OuterTemplate.GetSafeLink">
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="DisplayTitle">
<xsl:call-template name="OuterTemplate.GetTitle">
<xsl:with-param name="Title" select="@Title"/>
<xsl:with-param name="UrlColumnName" select="'LinkUrl'"/>
</xsl:call-template>
</xsl:variable>
<xsl:variable name="RowNum" select="count(./preceding-sibling::*)" />
<table>
<tr>
<td style="vertical-align:top;">
<table>
<!-- <xsl:if test="$RowNum < 4"> //to restrict the number of rows-->
<tr>
<td valign="top">
<a href="{$SafeLinkUrl}"><img border="0" height="50" width="80">
<xsl:attribute name="src"><xsl:value-of select="substring-before(substring(@Rollup, string-length(substring-before(@Rollup,
'/St'))+1,string-length(@Rollup)),',')" />
</xsl:attribute>
</img>
</a>
</td>
<td style="vertical-align:top;">
<table>
<tr>
<td style="color:#3A80B8; font-family:'Century Gothic'; font-weight:bold; font-size:12px" valign="top">
<xsl:call-template name="OuterTemplate.CallPresenceStatusIconTemplate"/>
<a class="NewsTitle" href="{$SafeLinkUrl}" title="{@LinkToolTip}">
<xsl:value-of select="$DisplayTitle"/>
</a>
<br />
<span style="color:#595959; font-family:Verdana; font-weight:bold; font-size:10px">
<xsl:value-of select="ddwrt:FormatDate(@Created, 2057, 3)"/>
</span>
</td>
</tr>
</table>
</td>
</tr>
<!--</xsl:if>-->
</table>
</td>
</tr>
</table>
</xsl:template>
6) Please “check in” the file and Now you can able to view you Custom style in Tool pane and under Presentation heading,
7) Select all the necessary properties in Content query web part and publish the page.
No comments:
Post a Comment