4

Ok I created my first master page and now I am working on page layout. I created a new "Publishing Content Type" page layout in SharePoint Designer whose content type was "Page". In that page I want to display an image slider. As I understand I need to make a web part of image slider and then insert into this layout.

My questions is how do I do that? No I am not talking about how to make a web part or image slider but what code do I write in page layout to add it? Do I need to add a web part zone in it (this is what I have heard) or a WebPartAdder?

4
  • Did you get this sorted, cant find a way to do this either...
    – Stephen
    Jan 21, 2015 at 11:09
  • You need a add a Web Part Zone in page layout. It is very simple to do and you can do it from SharePoint Designer. If you open page layout in SD, you will see icon Web Part Zone (or something similar) in the toolbar above. Simply click on it which will add web part zone and then save that page layout, create a new page, apply that page layout on that page and you will see that web part zone in which you can add a web part. Jan 21, 2015 at 20:21
  • I am using HTML page layouts...I get an error when adding the webpart...
    – Stephen
    Jan 21, 2015 at 20:27
  • You get error when adding web part or web part zone? Jan 22, 2015 at 13:06

1 Answer 1

2

In a SharePoint Designer situation, insert actual Web Part in the targeted Web Part zone after exporting it from any page.

This works best only if you plan to use it on a single Site Collection, as repeated deployments must be manually performed elsewhere. In such situations an automated deployment is recommended, and in such cases the best way to have a web part automatically provisioned for you is to use the AllUsersWebPart (in this case RootWebOnly ensures that your Page Layout is only deployed on the Top-Level site as it should be!).

One additional tip: Repeated deployments (via features) of the Page Layout - if already in use - must be performed by temporarily changing the Page Layout, updating it, and re-applying to all Pages (make sure the Content Type has the same structure across Page layouts to avoid using data)!

The example below could be used in an automated deployment via Features with a Module.

<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <Module Name="PageLayouts" RootWebOnly="True">
    <File Path="PageLayout\Home.aspx" Url="Home.aspx" IgnoreIfAlreadyExists="true">
      <AllUsersWebPart WebPartZoneID="Left" WebPartOrder="1">
        <![CDATA[ ]]>
      </AllUsersWebPart>
    </File>
  </Module>
</Elements>

See also example detailed here http://blogs.msdn.com/b/uksharepoint/archive/2011/04/04/provisioning-web-parts-to-a-page.aspx

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.