Friday, January 15, 2010

Modifying a Sharepoint Master page

We had a request to change some of the base layouts of a Sharepoint publishing site today, which turned out to be a lot easier than first expected.  the requirement was to remove the Search feature from the home page.

image

First off I figured I’d need to find some setting for the site but there were none obvious that control this area.  I was just about the modify the code on the server when it occurred to me that this is probably something in the Master Page that can be changed.

Changing a Sharepoint Master Page

First off you need to find out which master page your site is using, do this by going to Site Settings/Master Page.

image

Here you can see that the “default.master” is being served up.

Next we need to get a copy of that page so we can make the changes.  Do this by going to the “Site Settings/Master pages and page layouts” option and download a copy of the master file.

image

Edit this file being sure to keep the placeholders in the correct place as these are needed by Sharepoint.  In this case I wanted to remove the User control that displayed the search box.

image

becomes:

image

Next you upload the new file under a different name, check it in and then approve it.  Once you have completed this task it will be made available in the Site Settings/Master list for selection.

image

select this and click Ok.  Refresh the home page and the search box has now been removed.  The really good thing about this is that now we know how we can change the entire layout of a sharepoint page, basically everything can be modified as long as the content placeholders are left in your Masterpage.

image