How to: Customize the look of the SharePoint Content Search Web Part results

In my last post, I talked about how you can set up your SharePoint site to roll up content on different parts of the site using Content Search Web Part (CSWP).

In that post I mentioned we’d take a look at how you can customize the rendering of the display template for the items that are rolled up so rather than having generic results coming back in a generic look – you can brand them and make them look however you want. You can even have your results show as a slider etc with a bit of extra JavaScript magic.

In this post we’ll take a look at basic components which you’ll need to customize your display templates for the CSWP.

I’m going to be using default set up of Office 365 Developer site in SharePoint Online and steps here apply to at the time of publishing this post.

1. Navigate to the masterpage gallery on your developer site: click Gear | Site Settings | Master pages and page layouts
2. Open the folder: Display Templates | Content Web Parts
3. Download a copy of the Control_List.html and rename it to something like MyControlList.html … this is a file which we’ll be modifying to introduce custom results rendering
You will need to supply this file only if you like to add anything prior to repeating items being rendered, for example some sort of a header. If you only want to modify the actual repeating results and not add anything overarching at the top – you won’t need this file. In our case, I will create an new rendering template for the header section and add a piece of text so we can see how it appears

To do that you need to find the section in this file that starts with this:

<ul class="cbs-List">

and add anything you want to see before the list right before, similar to this:

<a href='[link to all results]'>View More</a>
<ul class="cbs-List">

Change the value in <title> to something like My Custom Rendering, since this is how the user will pick the template from the CSWP settings UI.

4. Save the file (with a new name, make sure) and upload it back to the Content Web Parts. When you save the file and accept the default properties, you will see that accompanying JS file was created.

5. For the items rendering template, find the file Item_TwoLines.html from Content Web Parts, download it and give it a new name, in my case MyItem_TwoLines.html

6. Change the value in <title> to something like My Two lines, since this is how the user will pick the template from the CSWP settings UI.

7. In here you need to locate the following piece:

<div class="cbs-Item" id="_#= containerId =#_" data-displaytemplate="Item2Lines">

and basically the piece above along with the structure is how each of your items will be rendered, so if you need to make any changes to the rendering, add images, add an expanding content – you can do it here.

8. Again, save this file (with a new name) and upload it back to the Content Web Parts. When you save the file and accept the default properties.

9. Now on to testing!
Add a new CSWP to the page and make sure it shows any content just for the demo purposes.

10. Access the web part properties and set the display templates options as shown below:
display templates

Provided of course you kept the names as in the example.
You will see instantly that the web part has a new grouping section in our case it was a View More link as well as any customization you added to the item display – it will show up here too!

end result CSWP renderinf

The benefit of this approach is that you’re reusing a CSWP back end functionality and get any rendering you want, heck you can even get a custom slider this way!



How to: perform data rollups across SharePoint site collections

Say you have a typical corporate site with a home page containing news, events and whatever else data you need on a typical site. Also, if it’s a typical corporate site, you’re also likely to have department sites and various team sites, some of which are site collections and other sub sites.
The structure may look close to the one below:

site collection structure

With a structure like above, it’s often that users ask to see various information published on the home page on their respective sub sites and vice versa. Whether those are news, calendar events, announcements or wiki pages – you can use SharePoint Content Search Web Part (CSWP) to achieve this goal. CSWP uses search index to pull information across multiple sites, also you have your usual security trimming etc.

Let’s take a look at an example where you can use CSWP to share announcement across sites.

1. Create a list of an announcement type (aka Announcements App) on the root site collection
2. Create a managed metadata term set (Gear | Site Settings | Term store management) representing Category of the announcement
This will allow our announcements to be categorized and administrator can chose to show rollups of certain categories only on specific sites

announcement categories

3. Back in our announcement list, add a new column to that list representing a category and make it a managed metadata type column, set the column to consume data from the term tree we have just created. Remember the name of it since we’ll need it later. In my case, for reference let’s call it MyAnnouncementCategories

category column term settings

4. Create an instance of at least one announcement which uses the term set column. This piece if very important since search will need to crawl this piece of content in order to create searchable properties which we’ll need later.

5. If you’re using SharePoint Online, at this point you will need to wait until search crawl has completed and picked up your content. From my experience it may take 1 or 2 hours until this is done. if you’re using on-premises environment, you can expect for the crawl to happen faster plus you can always trigger it and have your properties created within minutes.

6. Navigate to the site where you’d want to see the roll up of announcement and add an instance of CSWP, add a Content Search Web Part and access it’s properties

cswp properties

7. Click the Change Query button and switch to Advanced Mode

8. In here under the Query Text add the following:

(contentclass:"STS_ListItem") owstaxIdMyAnnouncementCategories:#1e44855f-c4d8-43a1-96cf-69bd67a51197

Above query filters all of the crawled items which:
-Are list items
-MyAnnouncementCategories is equal to desired taxonomy term representing a category you want to filter on. Typically after SharePoint completes it’s crawl of data and picks up managed metadata property, it will create a managed property representing taxonomy ID of the managed metadata column. The name of the column usually has a format of owstaxId[ColumnName] so in our case it’s owstaxIdMyAnnouncementCategories. The GUID following the filter can be taken from the term store management tool. For examaple, in my case the unique ID of the Category 2 is as shown below:

unique ID of the category

This means that you want to filter announcements by certain category on one site and by different category on another site – you can do such filtering by specifying the Id of the category.

The cool part of this is that if you chose a parent category Id, you will see all of the items tagged with a parent category and child categories.

9. Save the Web part properties and test the query.
Remember if you’re using SharePoint Online the crawl may take some time for new items to be picked up so you might want to create some demo content tagged differently prior to doing the whole web part configuration to give it some time.

In a next post, I’ll demonstrate how you can style the results returned by CSWP to make them look how you want.



SharePoint MVP for 2014/2015!

It’s that time of the year when summer MVPs are renewed and newly awarded MVPs are invited to a very special club.
First off, good news! I’m still in!
It never gets old, it’s always one of the most exciting news of the day … and it has been my 6th year that I will be a SharePoint MVP.
A lot has changed since and a lot of things are still coming …
Just a week ago or so I’ve been lucky to participate Microsoft Envisioning Tour, pretty good video you can see here:

The video looks pretty futuristic, but just as when 6 years ago when I first became an MVP, a lot of things seemed to be impossible, now are completely an everyday norm!

Like for example:
-I can actually view a Word Doc on my phone while my chauffeur is driving me to work ;)
-At my local RBC branch I can actually use a Surface like table where I can browse stuff while waiting in line
-HD TV walls are becoming bigger and bigger and more crisp … everywhere … can’t wait to have a wall like that in my living room in few years
-Nearly every platform has a digital marketplace and I can buy apps for most of the devices I use
-The cost of hosting this blog dropped 70% and it’s running on platform that knows how to scale automatically if all of the sudden one day I become celebrity
-etc etc

All I’m saying, that I am really excited to be part of this … never failing to surprise and amaze technological miracle, and meet and connect with people that make it happen. My main hope and desire is to continue orbiting and flying through this black matter and to connect and inspire others just as inspire me every day!

Now onto watching a well deserved 45 min of Netflix show!


SharePoint Summit – October 27-29, 2014, register now for an early bird!


As some of you may know, SharePoint Summit 2014 is coming again to Vancouver this year after a great success last year.

SharePoint Summit is here to give you a 360 degree view of the best practices and methodologies you will need to plan, implement and manage successful SharePoint-based solutions designed to meet your organization’s business needs and be adopted by your end users.

“Discover.Innovate.Build” are the main themes of this event, featuring MORE THAN 60 outstanding training sessions (3 of which are mine! yay!) to help you make the most of SharePoint and maximize your people’s productivity and effectiveness.
There is an early bird, so you better check it out now if planning to attend:

Hope to see you there!


How to: quickly embed PowerPoint decks the “slide share” style in your site in SharePoint Online

With SharePoint Online there is a cool Word, Excel, or PowerPoint document preview for the documents.

document preview in library

That’s great, but what if you need to embed the document with all of the preview capabilities right on the page and not only in a library view.
Well, you can actually do that fairly easily out of the box:

1. Upload your document to the document library on the SPO site
2. Open the document in a browser rendering mode – should be default in SPO
3. Click File -> Share -> Embed. This will be the same for PowerPoint, Word and other MS office apps.

Some options will differ for Word document versus PowerPoint for example:
Here are word document options:

word embed options

Here is the PowerPoint:

powerpoint embed

4. Copy the embed code and navigate to the page where you want to embed this
5. Add the embed code to the page

insert embed code

That’s it … now it will play as it was one of those SlideShare embeds.


Migrating google site content to SharePoint online: findings from the field

Recently I had to migrate bunch of Google sites to SharePoint online, and despite relative simplicity of this task I wanted to point out few things that stood out as potential problems or things to consider:


Google has a survey capability. SharePoint Online answer to this is Excel Survey which is a sweet feature, in fact I blogged about it a while ago. However, issue #1 – it appears that Excel Survey can only be created from OneDrive and not from a regular document library.

Regular document library options:
regular document library

onedrive document library

I tried creating the survey in OneDrive and moving it to the document library but that didn’t work.
The solution here could be training your users to create surveys on their OneDrive and then pointing to them from the site page.

Issue #2, if you have a survey with a choice list, you need to create a choice field and in choice fields you delimit choices by new line. Unfortunately, this means you can have only 1070 characters in that field so if you have say average (2-3 words) choices, you can only have up to 50 of those. Unlucky for me, I had double of that.

options limit

Yeah, there is really no solution for this except you breaking down the list into two lists. It’s really not going to look the best but … [insert your excuse here when you have one :)]

Public sites
Ok this is by far the most limiting in comparison to Google sites. So it’s no surprise when you try to create a public site in Office 365, you’re allowed to have only one public site per tenant; here you can see the option greyed out because I already have one site created:

only one public site per tenant

This makes sense from business standpoint since Microsoft is selling office 365 subscriptions for a very small fee per user. So technically you can sign up for a single user license and run the entire corporate internet on it – this will end up costing Microsoft a lot of money for a single $5+ subscription – this is my interpretation, so don’t take what I have said here as an official statement from MS.

Any way .. the problem is that you would think “Oh, I’ll just create subsites under my main public site and have them branded separately” …
No, you can’t do that either, you can’t create sub sites in office 365 public site.
no ability to add subsites

Well, technically you can using SharePoint designer (I’m sure that hole will be closed soon too), but as I read on one of the official responses on SharePoint Online support – public SharePoint Online sites containing subsites will not be supported. Which really means, if you do that and stuff stops working – you can’t complain about it, because you hacked your way in a first place.

creating subsite in SPD

… and … even if you did create a subsite and were ok that it’s not supported here is another problem:
your sub sites on a SharePoint Online public site will not be able to have a custom masterpage applied. Again, here you can use SharePoint designer to change the masterpage for a SPO public sub site but it will be all reverted by some automated process in few minutes.

To summarize, it’s not a good idea to create subsites for Public Site in SPO so drop this architecture and stop trying to hack around it.
The solution I can come up with, is that you really need to create a separate tenant for each of your public sites and if some pages require custom branding (like chrome and everything), you can create a page and apply an alternative masterpage right in that page.

More stuff to be posted as i uncover more gotchas, but hopefully this helps to get started!



How To: Set up SharePoint 2013 calendar view rollup from multiple calendars

Here is the situation: you have few departments or groups who use SharePoint calendar to track their stuff. Wouldn’t it be nice if you could roll up events from those calendar into some sort of dashboard or homepage. Requests like that are quite common, here is how you can do this out of the box with no code.

1. Create those department calendars on their respective sites
2. Create a calendar which will hold aggregated list of events
3. Add a test event into each of the “department” calendars

so far so good, right?

4. Go back to your “aggregated” calendar and click calendar overlays from the ribbon as shown below:

calendar overlays

5. On the next page click the New Calendar link. This is how you add rolled up calendars to this main calendar
6. Fill in the Display Name of one of the calendars to be rolled up
6.1 Pick a color
6.2 Pick the web URL where the calendar is and click Resolve
6.3 Pick a list (calendar) and the view (has to be calendar view and not a list view)

calendar rollup set up

7. That’s it, click ok and repeat steps 5-6 for all of the other calendars you want rolled up.

Here is the result with a couple of test events I’ve added:

sharepoint calendar rollup



How to: autogenerate Outlook events from SharePoint list item data

Wouldn’t it be nice to let your users click on a link and automatically get Outlook event based on the information from a list?
new event

Whether you have a custom list where you store data on a site, or out of the box list and want to let your users create outlook events on the fly within a workflow – there is a solution for this.

SharePoint has a this trick up it’s sleeve where you can request an ICS event by passing in a list item ID, the list, and few other static parameters. For example:

http://[server or site URL]/_vti_bin/owssvr.dll?CS=109&Cmd=Display&List={4240AC62-593C-4FD5-9C41-8B0CCAF5D09A}&CacheControl=1&ID=20&Using=event.ics

calendar URL

Above you see a List parameter which is a list ID which can be extracted from the query string by going to list settings of any desired list:

list guid

You can also see an ID of the actual item.

One thing you have to remember is that each event needs a Start and End date otherwise your auto generated event will have random dates.

Here is the trick to autogenerated invite to pick up your dates. Create 2 columns EventDate and EndDate in your list of type DateTime:



Once created you can rename them to a more friendly name.
That’s it, enjoy!


Online Class: Building Compelling Branding for SharePoint Online Internal & Public Sites

On May 8, 2014 – 11am to 3pm Eastern USA time I’ll be doing an online class on Building Compelling Branding for SharePoint Online Internal & Public Sites.
This class is for designers, content managers, administrators and developers who want to learn about SharePoint Online (Office 365) Branding, Site Customization and Management.

Here is what you can expect from this class

Intro, purpose (15 min)
Overview of SharePoint Online sites and how they differ from one another (15 min)
-WIKI site, Team site, Public site, when do you use one and what are they for?

Customization options: SharePoint Designer versus Visual Studio (15 min)
-In this part, we’ll take a look at two of the most common customization options and
see some of the advantages in terms of using SharePoint Designer versus Visual Studio
for various business scenarios

Getting started with branding of a SharePoint Online site (30 min)
-Looking at key branding artifacts such as masterpages, stylesheets, page layouts and
how all of those can be branded, which tools to use and how it all comes together

Creating a SharePoint Online custom look (30 min)
-Custom look in SharePoint Online is the easiest way to get the most of branding; in
this part of the session we’ll take a look at what’s involved in creating your own custom look
and how to use it on the site. (Deliverable: sample custom look)

Applying more complex branding to SharePoint Online site by using master pages (30 min)
-Master page will give you the most power in terms of changing the look of SharePoint Online site; it’s a key to applying corporate brand so in this part we’ll focus on masterpage customizations and related content. (Deliverable: sample master page)

SharePoint Online public sites and how to brand one (30 min)
-SharePoint Online public site have a lot in common with the intranet sites but also few things different. The focus in this part of the session will be using branding features available in SharePoint Online public site to customize your own

Design manager and its role in packaging SharePoint online branding(15 min)
-In this part, we’ll see how you can easily transfer all of your SharePoint Online site customizations to a production site

Building interactive components for SharePoint online (15 min)
-If you found some cool JavaScript on the internet or creating something of your own, in this part, we’ll see what’s involved in having this customization packaged and deployed to your site
Deliverable: SharePoint Online app

Next steps/Questions (15 min)

Hope to see you there!