You might have this requirement in the following scenario: your master page needs to display dynamic information (for example Calendar Web Part, Weather Web Part or Twitter which both can be done with XML Viewer Web Part or dynamic HTML from a SharePoint List displayed with CQWB – Content Query Web Part).
This can be easily solved with SharePoint Designer. Please find bellow the full scenario described:
As a first step you need to create a new place holder within the Site’s Master Page. So, in SharePoint Designer open your Publishing Site Collection and then browse to the current master page.
If you don’t know which master page is your site using, just open the site in Internet Explorer. Browse through Site Settings (click Site Actions Menu -> Site Settings). Then in the Look and Feel section, click Master Page to identify it.
Good. Now let’s go back to SharePoint Designer. Please check out the Master Page and then open it for editing.
The next step is to add a new ASP Content Place Holder. In my example I will add it after the “PlaceHolderMain” Content Place Holder. This place holder will be override in the Page Layout and used to host a new web part zone and the “automatically added” web part which can display my dynamic content:
<asp:ContentPlaceHolder id=”StadlerWebPartArea” runat=”server” />
Now check in the master page, publish it and approve it from the Master Page library.
Go back to SharePoint Designer and in the Page Layouts Library identify the Page Layout(s) which is(are) currently used in you Site Collection. Then check it out for edit. In this example I’m using “Article Left” Page Layout.
Now it is time to override the content place holder created within the master page. Please insert it into the page after the “Register Tag” section.
Then from the Ribbon Menu click Insert and then Web Part Zone Button.
Save the page layout (the quickest way is CTRL+S) and then from the Ribbon Menu click Insert again but this time click on the Web Part Button (I will add a CQWB – content query web part).
Add a Web Part. Save the page, check it in and approve it. Now the work should be done.
To test it go to your publishing site and create a new page using the layout customized earlier. (in my case this is “Article Left”)
After you click Create button you should be redirected to the new page which is in edit mode. In the page you will see your pre-added web part (in my case a CQWP). This web part will be automatically added to all the new pages which will use this layout.
Tags: add a web part in the master page sharepoint 2010, add a web part in the page layout sharepoint 2010, add web part sharepoint designer, sharepoint 2010, sharepoint 2010 page layout, sharepoint 2010 web part zone
Trackback from your site.