Sharepoint 2010 Publishing Page Layouts

Its often you want to make a new sharepoint publishing page or to update an existing one strait via code. In csharp, thanks to microsoft’s ever improving sharepoint support this is really easy. One of the key points when updating publishing pages however is getting and setting the right page layout.

You can use code like this to cycle through the available page layouts, this can be the easiest way to find the one you want.

Note: sometimes you need to enumerate to find the right one!

foreach (PageLayout lo in pubweb.GetAvailablePageLayouts())

//some code for page layouts


…and to set the page layout of a sharepoint 2010 publishingPage in csharp you usually just include it in the edit code. We will post more about this in the future.

Here is the different page layouts (defaults – if you create your own you will have to set a page to use it then use code to find the correct name – or just be sure you know it beforehand) and their sharepoint values – you can use these to programmatically set the layout of a sharepoint 2010 page in csharp (migration code is a prime example.)

(Article Page) with Body Only pagefromdoclayout.aspx
(Article Page) with Image Left articlesleft.aspx
(Article Page) with Image Right articlesright.aspx
(Article Page) with Summary Links articlelinks.aspx
(Redirect Page) Redirect Page redirectpagelayout.aspx
(Welcome Page) Advanced Search advancedsearchlayout.aspx
(Welcome Page) Blank Webparts Page blankwebpartpage.aspx
(Welcome Page) People Search Results Page peoplesearchresults.aspx
(Welcome Page) Search Page searchmain.aspx
(Welcome Page) Search Results Page searchresults.aspx
(Welcome Page) Site Directory Home tabviewpagelayout.aspx
(Welcome Page) Welcome Page with Table of Contents weclometoc.aspx
(Welcome Page) with Summary Links welcomelinks.aspx
(Welcome Page) with Webpart Zones welcomelayout.aspx
(Welcome Page) with Splash Page welcomesplash.aspx

One Response to “Sharepoint 2010 Publishing Page Layouts”

  1. [...] Sharepoint Code Sharepoint 2010 | Sharepoint coding in Csharp | Code migration for Microsoft office share point | « Sharepoint 2010 Publishing Page Layouts [...]

Leave a Reply