SharePoint team and Project server team at offshoresoftwaredevelopmentindia.com has great experience of creating web application based on MOSS 2007 and Project server 2007. That includes customization and development of webpart, site definitions, theme development, extension development, module creation. The team has developed CRM application, Job portal, Project management, to CMS applications based on MOSS 2007 and project server 2007.
Team would like to share same experience. This can help who wanted to begin with the sharePoint development and Project Server development.
There are list of articles start with SP and from number 1 to …. Always start with the article SP1 and read next article to start working on MOSS easily and quickly.
Publishing Page Layout using a Feature:
This is the post on creating site columns, publishing content types and page layouts using features:
This post describes how to create a publishing page layout and deploy it using a custom feature. Now that we have a custom publishing site columns as well as custom publishing content types defined using a feature, the next step is to create the page layout.
Publishing page layouts map to the custom fields of a publishing content type. The files are placed in the Master page gallery (Site Actions > Site Settings > Modify All Settings > Galleries section > Master pages and page layouts).
Creating the page layout:
The page layout can be created by using Visual Studio 2005. It’s really an .ASPX page and some basic Intellisense works for the SharePointWebControls and PublishingWebControls.
If you need information on how to create your custom page layout there is a very good article on MSDN:
Customizing and Branding Web Content Management-Enabled SharePoint Sites (Part 1 of 3): Understanding Web Content Management and the Default Features.
Important to remember here is that you are dependant from the Master Page that will be used together with your page layout. In this article I’m using the default Blue Bland one; so all the default Content placeholders are available.
Snippet of the page layout (download all the files from the link at the bottom of the post):
Tip: to quickly create and test a page layout for my custom content types I sometimes use SharePoint Designer 2007 (SDP). Create the page layout by choosing “New > Page Layout” in the Master pages gallery. Be sure to choose your custom page layout:
Then open the page using SharePoint Designer. Add your HTML and design elements and drag your custom properties to the page. HTML page design is really not my thing so this is an easy way to add some tables and layout to the page. Once you have the page ready in SPD, save the file, check in and test it by creating a new page.
You can now use the HTML and controls from this page when creating your custom page layout using Visual Studio.
Note that SPD saves the page directly into the SharePoint database and not on the hard drive. So this is just a fast way to start up the creation of your page layout but it does not allow you to deploy the page easily to other servers.
Creating the provisioning xml schema:
To provision the page layout and any used CSS, images or other files we create a XML file that will be picked up by the feature and install the files in the corresponding libraries in your publishing site.
In my example I have one custom page layout with just one image. I could as well have several images and CSS files installed using the same feature. I guess you get the idea with this image sample.
<Module Name=”ProductPageLayouts” Url=”_catalogs/masterpage” Path=”PageLayouts” RootWebOnly=”TRUE”>
<File Url=”ProductDetail.aspx” Type=”GhostableInLibrary”>
<Property Name=”Title” Value=”$Resources:pagelayout_product_name;” />
<Property Name=”MasterPageDescription” Value=”$Resources:pagelayout_product_description;” />
<Property Name=”ContentType” Value=”$Resources:cmscore,contenttype_pagelayout_name;” />
<Property Name=”PublishingPreviewImage” Value=”~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/DefaultPageLayout.png, ~SiteCollection/_catalogs/masterpage/$Resources:core,Culture;/Preview Images/DefaultPageLayout.png” />
<Property Name=”PublishingAssociatedContentType” Value=”;#$Resources:contenttype_productbase_name;;
<Module Name=”ProductLayoutImages” Url=”Style Library” Path=”Styles” RootWebOnly=”TRUE”>
<File Url=”images/line.jpg” Name=”product/images/line.jpg” Type=”GhostableInLibrary” />
(Note: the value for PublishingAssociatedContentType above contains a break for HTML display reasons. You should put the value in one line).
I must say not much is available in the MSDN documentation about the schema for provisioning publishing pages. Like in other cases I looked at the PublishingLayouts feature delivered with the MOSS 2007 installation. This is a hidden feature that provisions the standard page layouts, master pages, etc for a MOSS Publishing site. You can find the feature here: C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\PublishingLayouts.
Some clarifications to the schema elements:
<Module Name=”[your module name]” Url=”virtual path destination of the module elements ” Path=”path from within this feature”>
This property specifies to which the page layout you are installing is mapped to. The syntax is
Every element has the property Type=”GhostableInLibrary”. This property is important because it will install the file in the Master Page gallery, but the actual file content are still stored on the hard drive and not directly in the SharePoint database (as is the case if you create your page layout using SDP).
Wrapping it up: creating the feature:
I’m using one single feature to create my custom publishing fields, custom publishing content type and custom page layout(s).
The feature now has the following structure:
Three XML files are referenced by the feature schema in the order in which they should be installed.
- myfields.xml: this file defines all my custom site columns.
- ProductContentTypes.xml: this file defines my two custom publishing content types and uses the custom field defined in myfields.xml.
- PageProvisionedFiles.xml: this file contains the provisioning for page layout and associated image.
I think the order in which these files are referenced in the feature schema are important because the site columns must be created before the content types, and the content types must be created before the page layout can reference it.
So, I have no proof that this really executes in the order defined in the feature schema but I do assume it is the case. Maybe someone has found some documentation on this?
<?xml version=”1.0″ encoding=”utf-8″?>
Title=”My publishing content type”
<!– Add a dependency to the Publishing site–>
<ActivationDependency FeatureId=”F6924D36-2FA8-4f0b-B16D-06B7250180FA” />
That’s it, the feature is complete.
All that needs to be done is copy the feature directory to “C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\FEATURES\MyContentTypeFeature” and run the install command.
stsadm -o installfeature -filename MyContentTypeFeature\feature.xml
This command can be used to install and test the feature. For a production environment I would recommend creating a SharePoint solution that installs the feature and all its files.