Home > Publishing, SharePoint, Web Part > Create a blank publishing page in SharePoint 2010 for a print view or hosting in an iFrame

Create a blank publishing page in SharePoint 2010 for a print view or hosting in an iFrame

There are a few occassions when a page’s content could be useful without the associated branding and navigation elements being visible.  For example if you want to create a print view or host SharePoint content in an iFrame.  In my case I wanted to host the Organization Browser web part within an iFrame using a Content Editor Web Part.  This would enable me to access the same page on multiple sites, getting different content by setting querystring values in the CEWP and overcoming the issue of adding querystrings to URLs breaking SharePoint navigation.

First you need to create a new masterpage using SharePoint Designer, to do this take a copy of your existing custom masterpage or default.master and name it blank.master. Edit the file in Advanced Mode and find the main table which starts with <table class=”ms-main”.  Now add this style=”display:none” tag to the end.  It should look something like this:

<table cellpadding=”0″ cellspacing=”0″ border=”0″ width=”100%” height=”100%” style=”display:none”>

Next find this content holder <asp:ContentPlaceHolder id=”PlaceHolderMain” runat=”server”></asp:ContentPlaceHolder> and copy this to the clipboard, delete it from it’s original location and place it under the closing tag for the main table.  Also, to avoid scrollbars appearing in my iFrame, I amended to the body tag to set scroll=”no”.

Checkin, publish and approve your new masterpage.  Now if you haven’t already, create the content which you wish to host in the blank master page, then return to SharePoint Designer.  Next we need to detach the content page from it’s Page Layout, so open the library which contains your content, select the file, right click  and choose Detach from Page Layout then click Yes to the warning.  If the library is under source control, click Yes to check it out.  Now right click again and choose Edit file in Advanced Mode.

Now replace this line:

<%@ Page language=”C#” Inherits=”Microsoft.SharePoint.Publishing.PublishingLayoutPage,Microsoft.SharePoint.Publishing,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c” meta:progid=”SharePoint.WebPartPage.Document” meta:webpartpageexpansion=”full” %>

with this:

<%@ Page language=”C#” MasterPageFile=”~/_catalogs/masterpage/blank.master” Inherits=”Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint,Version=14.0.0.0,Culture=neutral,PublicKeyToken=71e9bce111e9429c” meta:progid=”SharePoint.WebPartPage.Document” meta:webpartpageexpansion=”full” %>

Save the file and if all is well, you’ll see the content without branding and navigation.

As you can see from the changes, this content now inherits from Microsoft.SharePoint.WebPartPages.WebPartPage which enables the MasterPage to be set.  With Microsoft.SharePoint.Publishing.PublishingLayoutPage this isn’t possible without custom code overriding OnPreInit.

  1. No comments yet.
  1. No trackbacks yet.

Leave a comment