How to Create a Page Layout (PageLayout) with ContentType in SharePoint 2013 using Design Manager – Part III

Sathish Nadarajan
 
Solution Architect
November 16, 2013
 
Rate this article
 
Views
41889

In this article, let us see how to create a PageLayout using Design Manager. In the previous article, we saw about the creating a page layout using Visual Studio, SharePoint Designer. Here let us utilize a new feature in SharePoint 2013, which is not available on SharePoint 2010 – Design manager.

Design Manager is a new feature which is available only in SharePoint 2013 (not in the previous flavors of SP), that allows us to easily create the branding artifacts like MasterPages, CSS, PageLayouts Etc.,

Design Manager will be available only in Publishing template and not in the Developer Site Template. Hence, we need to create a Publishing Site for this demo.

Let me create a publishing Site.

clip_image002

On the Settings Icon on the Right top corner, you can find a new link called Design Manager.

clip_image004

Design Manager will look like this.

clip_image006

Click on the Edit page Layouts link.

clip_image008

Click on the Create Page Layout.

clip_image010

Enter the name for the pagelayout and select the Content Type which we created.

clip_image011

Keep the master page as it is as of now. Since, we are not focusing that.

Now, we got the html file inside the pagelayouts folder.

clip_image013

Let us, publish this. Then the “Approval Status” will become “Approved”

clip_image015

Now, let us go to the Pages document library.

Associate this doc library into our Content Type which we created. To add our Content Type, follow the steps.

clip_image017

Go to Library Settings.

clip_image019

clip_image021clip_image023

That’s it. Now we added our Content Type.

To confirm that, go to the Files-> New Document. Our newly added content type will be listed there.

clip_image025

On the Create Page, you can find the Page Layout, which we created using the Design Manager.

clip_image027

Let me create a page based on the page layout we created.

After giving the mandatory fields, our page will look like the below.

clip_image029

Now, let us see, how to modify the layout of the Page Layout which we created. To see that, go to Master Page Gallery.

clip_image031

You can find the list of files, and the one which we created just now. For every PageLayout, created by the designer would be having 2 files. One aspx and one html. In our case, PageLayoutDesignmanager.aspx and PageLayoutDesignManager.html.

As far as concerning the Design manager approach, html file is very important. The aspx page will be overridden by html template when next time, sharepoint gets loaded. Hence, it is strongly recommended that not to modify the aspx. Modify only the html.

Being a developer/designer, we can use any tool to modify the html. To do that, we need to map the galleries into our local computer.

Open the Windows Explorer and Select Map Network Drive.

clip_image033

Enter the folder as the url of the masterpages gallery.

clip_image035

Now, the folder would be mapped to our local machine.

We can see the files, which we were talking about.

clip_image036

Now, open the html in your favourite editor and modify the layout. Let me open it using the visual studio itself.

The page is a mixture of pure html code and commented aspx

clip_image038

For instance in the html file, remove the following selection that displays the Title field in the Page Title:

clip_image040

As soon as you do it, the modification will be reflected in the associated aspx page:

clip_image042

Now, let’s create a new Page Content from our new JobPosting page and you will see that everything works as expected.

When saved, the page looks like this:

clip_image044

There are no fields labels.

So update the html file with the following spans :

clip_image046

When you make any modification to the html file, don’t forget to Publish a Major version of the file (in the Master Page and Page Layouts gallery).

clip_image048

Now, we are going to redeploy the package.

Go to Design manager and Select Create Design Package.

clip_image050

clip_image052

On clicking the Create,

clip_image054

By clicking the download, we can download our package.

The downloaded will be a WSP and we can open the WSP using visual studio and see, the artifacts. Then we need to copy those files and put in a separate visual studio solution to deliver the package alone.

Happy coding.

Sathish Nadarajan.

Author Info

Sathish Nadarajan
 
Solution Architect
 
Rate this article
 
Sathish is a Microsoft MVP for SharePoint (Office Servers and Services) having 15+ years of experience in Microsoft Technologies. He holds a Masters Degree in Computer Aided Design and Business ...read more
 

Leave a comment