My First Post – SharePoint Customization to a new level

So finally I have got hooked to the blogs phenomena and have decided to join the "Blog Bandwagon". Although I am a rookie with SharePoint, but I guess I can also contribute my share to the vast ocean of SharePoint Knowledgebase.

So as the first post for my blog I would be discussing on some cool requirement where my customer required help in implementing – “How to restrict the available page layouts in a custom site definition”.

So the possible approaches to implement this would be:-

Strategy 1: Make changes in the Custom Site definition’s Onet.Xml file:

Steps to achieve this solution:

1.       Open the onet.xml of the custom site definition. This can be found typically at (DriveName\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\Templates\CUSTOM SITE DEF\Onet.XML).

2.       Find the webfeatures tag.

3.       Find the property AvailablePageLayouts and add the highlighted code below to the value part of the property.

<Property Key="AvailablePageLayouts" Value="~SiteCollection/_catalogs/masterpage/RedirectPageLayout.aspx:~SiteCollection/_catalogs/masterpage/WelcomeSplash.aspx"/>

4.       Do an iisreset or reset the application pool of the site


(+) of this approach - as I see it:

a.       All changes are made in the configuration file, hence no code involved.

b.      Good for new sites to be created.

(-) of this approach - as I see it:

.       a.   Provides little or no support for existing sites


Strategy 2: And of course, you can make changes to the page layout collection through code:

As I always say “Never underestimate the power of a Developer, more so a SharePoint Developer”. You require a small piece of code to achieve the requirement.

I have written the sample code piece using Object Model and this could very easily be implemented in the FeatureActivated event handler.


SPSite thisSite = new SPSite("http://MOSS Site URL");

SPWeb thisWeb = thisSite.OpenWeb();

      PublishingSite thisPubSite = new PublishingSite(thisSite);

      PublishingWeb thisPubWeb = PublishingWeb.GetPublishingWeb(thisWeb);

      PageLayoutCollection myLayouts = thisPubSite.GetPageLayouts(true);


// Create a temp array

      // Copy required page layouts to the temp array

      // You can write your custom code to pick the required layouts

      // Possibly a for loop can also be used

      PageLayout[] msTemo = new PageLayout[3];

      msTemo[0] = myLayouts[0];

      msTemo[1] = myLayouts[1];

      msTemo[2] = myLayouts[2];


      // Attach the temp array to the SetAvailablePageLayouts Method

      thisPubWeb.SetAvailablePageLayouts(msTemo, false);



(+) of this approach - as I see it:

a.       Works well for existing sites. Once a site is created simply execute the code or if the code is implemented using a Feature Activated, add this feature to the site definition and it would work seamlessly well.

b.      As a developer, I like this strategy as it gives me power to control the features and as well ease in maintenance.


(-) of this approach - as I see it:

a.       I know none.




Comments (7)

  1. Rajasthan Tour Package says:

    Rajasthan is a popular tourist destination in India. It is the largest state in India to have many attractions to offer its visitors. There are many fascinating tourist attractions in the state dotted with several attractions catchy. The state is globally famous for its unique cultural and geographical characteristics. Desert, mountains, sand dunes, forests, flora & fauna, etc are the geographical characteristics of the state.

  2. guest house in jodhpur says:

    I enjoyed to be at here because one of my point has been cleared here.

    Blogs are becoming the main source of knowing about things certainty,its

    importance,idolizing,either in a marketing way that one can differentiate.

  3. exporters of fresh flowers says:

    Nice post! I loved it your way of information..Good blog, great PIcs. I need more tips & info for this..

  4. exporters of fruits and vegetables says:

    Keep up the good work.Your article is really great and I truly enjoyed reading it.Waiting for some more great articles like this from you in the coming days.

  5. Wholesale Gold Jewellery says:

    I am really moved by the points mentioned in the blog, which I have read no where else. It has been a real pleasure to visit this site.

Skip to main content