Design Manager in Sharepoint 2013/Office365

The earlier blog post was specific to creating master pages and page layouts using Design Manager. You can find it here. This post is an overview of the Design Manager.

Design Manager
Design Manager is available when we activate publishing features that are available in publishing sites in both SharePoint Server 2013 and Office 365.

img 1.1

img 1.2
In case we want the SharePoint 2013 site to represent our organization’s brand and not “look like SharePoint,” we can create a custom design and use Design Manager to achieve that goal. Design Manager is a feature in SharePoint 2013 that makes it easier to create a fully customized design by using the web-design tools like editors of our own choice that we are already familiar with using only HTML and CSS, and then upload that design into SharePoint. Design Manager is the central hub and interface where you manage all aspects of a custom design.
img 3.1

  • Welcome
    In case we want the SharePoint 2013 site to represent our organization’s brand and not “look like SharePoint,” we can create a custom design and use Design Manager to achieve that goal. Design Manager is a feature in SharePoint 2013 that makes it easier to create a fully customized design by using the web-design tools like editors of our own choice that we are already familiar with using only HTML and CSS, and then upload that design into SharePoint. Design Manager is the central hub and interface where you manage all aspects of a custom design.
  • Manage Device Channels
    In case we want the SharePoint 2013 site to represent our organization’s brand and not “look like SharePoint,” we can create a custom design and use Design Manager to achieve that goal. Design Manager is a feature in SharePoint 2013 that makes it easier to create a fully customized design by using the web-design tools like editors of our own choice that we are already familiar with using only HTML and CSS, and then upload that design into SharePoint. Design Manager is the central hub and interface where you manage all aspects of a custom design. Below is a link where we can look for User Agent Strings.
    http://www.useragentstring.com/pages/useragentstring.php
    For testing, we can use the query string “?DeviceChannel=alias” within a browser to preview our site for a specific channel.device channels
  • Upload Design Files
    The easiest way to upload and continue to work on design files is to map a drive on our computer to the Master Page Gallery of our SharePoint site. This connects a folder on our computer to the Master Page Gallery, so that we can work on files that reside on the server in SharePoint 2013 as if they were local files.
    Mapping the following location as a network drive allows us to work easily with our design files. After we map a network drive, we can upload our design to SharePoint simply by copying the design files to a folder on the mapped drive of our computer that is connected to SharePoint. After we convert our HTML file to a SharePoint master page, and after we create page layouts and display templates that each have their own associated HTML file, we can continue to edit those associated HTML files in our HTML editor on our computer. SharePoint automatically synchronizes the files on our computer with the Master Page Gallery.We can use this drive to, Upload the HTML version of our Master Page, Upload CSS and js files and any other design assets and Access design files for editing.upload design files
  • Edit Master Pages
    We can use the network drive we mapped earlier to edit our master pages using any HTML editor. To preview our master page, we need to click on its file name or status. While previewing our HTML master page, we can use the Snippet Gallery to get code snippets for SharePoint functionality that we can copy and paste into our HTML file.
    Creating a fully branded master page that contains all of the SharePoint functionality that you want consists of converting an HTML file into a SharePoint master page, previewing the master page and fix any issues and adding SharePoint snippets to the master page.
    Convert an HTML file
    The core feature of Design Manager is that it converts our HTML design into a SharePoint master page. When we convert an HTML file to a master page, Design Manager creates a .master file that contains all of the required elements. During conversion, some HTML markup (such as comments) also gets added to our original HTML file.After the conversion, our HTML file and the SharePoint master page are associated, so that when we edit and save the HTML file in our mapped drive, the master page is updated automatically. In Design Manager, the HTML master page has a property named Associated File that determines whether changes to the HTML file are synced to the .master file.
    Minimal master page
    Design Manager also provides an option to begin our design by using a minimal master page. In this scenario, you don’t have to begin with an HTML design; instead, you can create an HTML master page that contains the minimum page elements necessary to render the master page correctly in SharePoint, and then build out our design by editing the HTML master page.edit master page
  • Edit Display Template
    Search results and other search-related web parts rely on display templates to control the appearance and behavior of search results. The best way to create a new display template is to copy an existing one that’s similar to what we want and then change yours using any HTML editor. We can use the Content Search Web Part and other search-driven Web Parts to display the results of search queries as content on our pages.
    With master pages and page layouts, you edit an associated HTML file but not the .master file or .aspx file. Similarly, display templates are made of an HTML file and an associated .js file, where you edit only the HTML file. Each time you save that HTML file, SharePoint automatically updates the associated .js file.
    When you want to create a custom display template, you should begin by copying and then modifying one of the existing display templates. This is helpful because the default display templates contain information in comments in the HTML files, and you’ll have the proper basic page structure and a framework in place for basic tasks like mapping input fields.
  • Edit Page Layout
    Page layouts define the look and feel of a set of pages by styling page fields and web part zones within the common elements of a master page. We can use the network drive we mapped earlier to edit our page layouts using any HTML editor. To preview our page layout, click on its file name or status. While previewing our HTML page layout, use the Snippet Gallery to get code snippets for SharePoint functionality that we can copy and paste into our HTML file.
    The process for creating a page layout is a bit different from that for creating a master page. For a master page, you start with an HTML design, convert that into a SharePoint master page, and then continue to edit the associated HTML file. But for a page layout, we first create the page layout in Design Manager, which creates an “.aspx” file and an HTML file, and then we edit the associated HTML file from the mapped drive in your HTML editor. The reason we have to use Design Manager to create a page layout is so that the correct set of page fields can get added to the page layout.
    When you create a page layout, we select a master page with which to preview your page layout, and we select a Page Layout Content Type. A content type is a schema of fields and data types, and the fields available in the page layout content type determine what page field controls are available on the page layout that we design. We create a page layout in the browser first so that the page fields can be added.
    After we create a page layout with its associated HTML file, the remaining steps are the same as for a master page.edit page layout
  • Publish and Apply Design
    Once the visual design of your site is complete, we need to make sure we have published our files master pages and page layputs and site assets like css and js files. It provides link to gallery location to which we’ve saved design assets like images, CSS, and JavaScript files to publish them and set master page to different device channels.
  • Create Design Package
    Once the visual design of your site is complete, we need to make sure we have published our files master pages and page layputs and site assets like css and js files. It provides link to gallery location to which we’ve saved design assets like images, CSS, and JavaScript files to publish them and set master page to different device channels.

Creating master pages and page layouts with design manager in sharepoint 2013/Office365

The following blog post follows steps to be followed to get started with Creating master pages and page layouts with design manager in sharepoint 2013/Office365.

I have created master pages and page layouts in Office365 using design manager. It follows a step by step details and by the end of the blog you will have your own demo blog site template ready which uses master page and page layout.

I have replicate the Bootstrap blog template that is available over here.

  • activate features to enable design manager
    Site collection administration-> Site collection features->sharepoint server publishing infrastructureSharePoint Server Publishing Infrastructure (under Site collection features)
    img 1.1Site action-> Manage site features->sharepoint server publishing.SharePoint Server Publishing (under Manage Site Feature)img 1.2
  • Under look and feel you will find design manager.img 2.1
  • Click on edit master pagesimg 3.1
  • Insert the site collection url address. Eg:- https://example.sharepoint.com/sites/dev.
    1. Login with credentials.
    2. Open the site collection and upload the masterpage html document.
    3. Also upload the files under style library folder, check out, check in and publish them as a major version.
    4. Open sharepoint designer upload our html file under _catalogs/master pages. You will find it under All Files->_catalogs->masterpages.
    5. Create required folder structure and upload the remaining files. Follow the same checkout, check-in and publish process for rest of the files. Usually the resources go under Style Library but in this demo we create it under Masterpage library itself.
  • Go to design manager, click on convert file to master page. Browse and select our html document.img 5.1 img 5.2Select blog.html. After that click on insert.
  • It will automatically create another file with same name and extension as .master. The changes made in html file are synced to the master page automatically. You can now go to SP Designer refresh the site and see the changes.img 6.1
  • Open the master page in SP designer, edit it and make the necessary changes.
    Remove the markup of page layout from html page with a div attribute data-name=ContentPlaceHolderMain. You will see code something like below that is selected by user. Place this code inside container div.img 7.1Save it checkout, check-in and publish as a major version.
  • Next step to create a page layout. Select edit page layout option in left nav then the create a page layout.img 8.1Select the master page and default content type.img 8.2Click on the layout name and open the preview.img 8.3
  • Open layout in sharepoint designer. You will see two pages with same page layout name. Edit the html page.
  • Inside the tags of ContentPlaceHolderID with ID as PlaceHolderMain you will find html markup with some sharepoint code.
    <!–MS:<asp:ContentPlaceHolder ID=”PlaceHolderMain” runat=”server”>–><!–ME:</asp:ContentPlaceHolder>–>

    img 10.1These are preadded webparts by default in the page layout, we will delete them and add our own html markup for our page layout.

  • Take out the not required text and snippets and keep only the structure we want to keep for our page layout in which we will copy paste the web part zone.img 11.1
  • Visit our Design manager under page layout section click on the page layout that we created.img 12.1
  • On the top right we will see snippets option link. Next open the snippets link which opens a new page, there we will get the web part zones that we will copy to insert in our page layout later.img 13.1img 13.2
  • Copy paste the web part zones from the below copy to clipboard button. Rename the ids after pasting it in the html markup. Web Partzones must have unique id.img 14.1Changing the html markup of the page layout keep sync with the page layout “.aspx” page. Check out, check in the page and publish it as a major version.
  • Next up create a new page. You can hover on site settings menu, click on add page, it adds below the pages path. You can also select the page layout at this page.img 15.1 img 15.2Orimg 15.3
  • Click on created page and then edit that page. Select page tab and next page layout to select that page layout. Check in the page.img 16.1
  • Visit site settings and click on master pageimg 17.1Select the master page and click saveimg 17.2
  • Edit the page it will take the applied master page and page layout.img 18.1
  • You can now add webparts. Go ahead, add few content editors and text inside it.img 19.1
  • Add some text in it, save it.img 20.1
  • This is how it looks finallyimg 21.1
Note: In case you encounter any errors or issues check if both the publishing features are active or disable and reactivate it.

Intro to LESS CSS – Part 2

Operations:- Operations are functions or modifiers that we can apply to our rules. We can Add, Substract, Multiply or Divide.

Note:- LESS is aware of PX hence no need to mention measurement unit.

Color Functions:- Color functions are used to make variations in color. These functions are darken, lighten, fadein, fadeout, saturate, desaturate. Fadein and fadeout need opacity to be mentioned already.

Comments:- There are two ways in which we can comment.

/*This will appear in LESS to CSS file*/

//This will not appear in CSS file.

Importing:- When we mention file name we can mention .LESS or .CSS extention for the file that we are importing

E.G:- @Import “reset”

Escaping:- Old proprietory code causes LESS to error, hence we can escape using ~”-code-”

E.G:- filter: ~”progid:DXImageTransform.Microsoft.gradient(startColorstr=#fad59f, endColorstr=#fa9907)”

Scope:- Variables will inherit first from local scope, if not available locally it will search for wider scope

Spin:- We can use spin method to spin the color wheel by degrees to change color values. Its best to set only one color variable in LESS stylesheet and use modifiers throughout rest, then whole design depends on it.

Intro to LESS CSS – Part 1

If you are a frontend developer/designer some time in future you will run into LESS, which is a CSS preprocessor. LESS offers many benefit over plain vanilla CSS. IT make you working with CSS simple and fun. User can write dynamic CSS via LESS. The learning curve for LESS is very minimal.

We can write modular CSS using LESS. LESS includes variables, mixins, nested rules, operations, color functions and many more features. It is fun once you get used to it.

Below you will find examples which make you to easily understand LESS.

Variables Declaration:- They are time savers declare once and use it where required.

MIXINS:- They are resuable piece of code. Mixins allow us to specify a chunk of code as a class and then allow us to mix those classes together. They are divided in two types, Normal Mixin and Parametric Mixin.

A Parametric Mixin is same as normal Mixin but it takes parameters/arguments with Mixin.

We also can override parameters in it.

Example of Parametric Mixin with Variable.

NESTED RULES:- LESS allows users to write new CSS rules within curly braces of existing rules.

Displaying text/banners (page specific)

We often come up with a requirement that the specific page require banner images,  for example the default landing home pages. The most common requirement is that of carousel on the home page.

The general approach is to create page layouts for different design patterns. Below I am mentioning another approach to implement it.

  • Add an empty contentplaceholder in the master page.

In master page we set an ID in the contentplaceholder tag. This ID will be mentioned in the page layout where we insert content tag. This will insert an empty div into the html page that will be generated.

If you wish to add banner images or carousel we will add the following code in page layout, eliminating the need for another page layout specifically only for banner images or carousel images.

  • Add content tag in the page layout with the html markup.

Next when we visit the page with above mentioned code present in master pages and page layout respectively. The page will display “Sample text”.

Assign master page via page layout to only a single specific page

In a publishing site we have a master page that all the pages inherit. We can edit a page and assign page layouts through the page layouts options on top ribbon. It lists out all the page layouts are available. For a page layout to be available it should be checked in and published.

In current case where we want a single page layout to inherit a different master page other than the custom masterpage that is currently set. Usually setting a master page for a page is done as listed below.

But this alone is not enough, if also need few more things to set in the page layout.

  • Add a page and assign the page layout. Open the site in sharepoint designer, visit pages section where the page is saved and deattach the page layout from the page.
  • Next edit the page and remove the references of custom master page (custom.master) from the page.
  • Set our intended master page
  • MasterPageFile=”/_catalogs/masterpage/Different.master”

  • Remove the publishing feature registry at the top of the page

    Microsoft.SharePoint.Publishing.PublishingLayoutPage,Microsoft.SharePoint.Publishing

  • Replace it with webpart pages registry reference

    Microsoft.SharePoint.WebPartPages.WebPartPage,Microsoft.SharePoint

  • Save the page and publish it. Remember to keep the page layout detached, do not reattach it again.
  • Below is an example of the page after all the changes have been done.