Showing posts with label Publishing. Show all posts
Showing posts with label Publishing. Show all posts

Tuesday, April 19, 2011

SharePoint Custom Publishing Layout feature

Scenario:
I am surprise that I have used this so many times but never blogged this. We often need a custom content type and custom page layout.

Solution:
Here's quick snippet of Element manifest.

Content Type Provisioning Element Manifest:

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Parent ContentType: Page (0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF39) -->
<ContentType ID="0x010100C568DB52D9D0A14D9B2FDCC96666E9F2007948130EC3DB064584E219954237AF3900New_GUID_Here"
Name="Custom Page"
Description="Custom Page is the default content type for any Publishing Pages."
Group="SKN"
Inherits="TRUE"
Version="0">

<FieldRefs>
<FieldRef ID="{GetGUIDFromBelow}" Name="CustomColumn" />
</FieldRefs>
</ContentType>

<Field ID="{NewGUID}"
Name="CustomColumn"
DisplayName="Custom Column"
Type="Text"
Group="SKN">
<Default></Default>
</Field>

</Elements>
Page Layout Provisioning (with Default WP) Element Manifest:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
<Module Name="CustomPageLayouts" Url="_catalogs/masterpage" Path="PageLayouts" RootWebOnly="TRUE">
<File Url="CustomLayoutPage.aspx" Type="GhostableInLibrary">
<Property Name="Title" Value="Custom Page Layout Blank" />
<Property Name="MasterPageDescription" Value="$Resources:cmscore,PageLayout_BlankWebPartPage_Description;" />
<Property Name="ContentType" Value="$Resources:cmscore,contenttype_pagelayout_name;" />
<Property Name="PublishingPreviewImage" Value="~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/BlankWebPartPage.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/BlankWebPartPage.png" />
<Property Name="PublishingAssociatedContentType" Value=";#WH Page;#SAME_AS_CONTENT_TYPE_ID_ABOVE;#" />

<AllUsersWebPart WebPartOrder="0" WebPartZoneID="Header">
<![CDATA[<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="CustomCode.DefaultWp, CustomCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=abcdcc1c43254ae6" />
<importErrorMessage>Cannot import Default WP Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Title" type="string">Default Information</property>
<property name="Description" type="string">Description for Default WP</property>
</properties>
</data>
</webPart>
</webParts>]]>
</AllUsersWebPart>

</File>
</Module>
</Elements>
Content Type Association Element Manifest:
  <ContentTypeBinding ContentTypeId="CONTENT_TYPE_ID_FROM_ABOVE" ListUrl="Pages" />
New Page Provisioning using Layout ( with Test WP ) Element Manifest:
 <File Path="SampleBlankWPPage.aspx" Url="Home.aspx" Type="GhostableInLibrary" NavBarHome="True">
<Property Name="Title" Value="Custom Home" />
<Property Name="PublishingPageLayout" Value="~SiteCollection/_catalogs/masterpage/CustomLayoutPage.aspx, Custom Layout Page" />
<Property Name="ContentType" Value="Custom Page" />

<AllUsersWebPart WebPartOrder="0" WebPartZoneID="Header">
<![CDATA[<webParts>
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="CustomCode.TestWp, CustomCode, Version=1.0.0.0, Culture=neutral, PublicKeyToken=abcdcc1c43254ae6" />
<importErrorMessage>Cannot import Test WP Web Part.</importErrorMessage>
</metaData>
<data>
<properties>
<property name="Title" type="string">Test Information</property>
<property name="Description" type="string">Description for Test WP</property>
</properties>
</data>
</webPart>
</webParts>]]>
</AllUsersWebPart>
</File>

Thursday, March 11, 2010

Page Layout with Show Hide Title option

Scenario:
I think this is another common request from client. They need limited page layout but they need each layout to be very flexible. And one of them is that they should be able to decide to Show/Hide Title of the page.

Workaround can be to create 2 page layouts but thats lot to maintain for them.

title optional

Solution ( Approach 1 ):
Let me explain you the approach first.

1. Added a column/field to the Page Content Type - ShowTitle of the type Boolean

2. Added a column/field to the Page Content Type - TitleOnPage of the type Calculated Column with Formula :
=IF([ShowTitle],[Title],"")

3. Here's the Markup adjusted to handle the Show/Hide of Title

<asp:Content contentplaceholderid="PlaceHolderPageTitleInTitleArea" runat="server">

<WebPartPages:WebPartZone runat="server" Title="loc:TitleBar" ID="TitleBar" AllowLayoutChange="false" AllowPersonalization="false"/>

<span><SharePointWebControls:ListItemProperty ID="ListItemProperty2" Property="TitleOnPage" MaxLength=40 runat="server"/></span>
<span> <PublishingWebControls:EditModePanel runat=server id="EditModePanelB">

<SharePointWebControls:TextField runat="server" id="TitleField" FieldName="Title"/>
<SharePointWebControls:BooleanField FieldName="ShowTitle" runat="server" id="BooleanField1" />

</PublishingWebControls:EditModePanel>
</span>

</asp:Content>
Solution ( Approach 2 ):

Monday, July 27, 2009

Error creating an External Link

Scenerio:
While creating an External Link,

e

I got the following error.
Content type '0x01010007FF3E057FA8AB4AA42FCB67B453FFC100E214EEE741181F4E9F7ACC43278EE811' not found in web 'http://localhost'.

Reason:
I searched for the same word in 12 HIVE and found that its part of PublishingResources feature.

Few Options :
1. IISReset

2. Try running the following command from command line

STSADM -o activatefeature -name PublishingResources -url http://localhost
If the above command execute sucessfully , then IISReset

If you got the error "Feature 'PublishingResources' is already activated.
3. Try the force attribute like this :
STSADM -o activatefeature -name PublishingResources -url http://localhost -force
and then IISReset.

Saturday, August 23, 2008

One or more features must be turned on before this feature can be activated.

Scenario:
You are trying to activate Office SharePoint Services Publishing feature and get following error.

Error SP2010:
The SharePoint Server Publishing Infrastructure feature must be activated at the site collection level before the Publishing feature can be activated.


Error MOSS 2007:
The Office SharePoint Server Publishing Infrastructure feature must be activated at the site collection level before the Publishing feature can be activated.


Reason:
The publishing feature (Site Feature) is dependend on the Publishing
infrastructure feature (Site Collection Feature).

Resolution:
For activating the feature, go to

1. Navigate to your Top level site and click on Site Actions > Site Settings 
2. Under Site Collection Administration, click Site Collection Features
3. Click on Activate for Office SharePoint Server Publishing Infrastructure
4. Once that’s activated, Navigate back to site settings page of the site you was getting error.
5. Under site administration, click on Site Features
6. Now Activate Office SharePoint Server Publishing.

Done!!!