26 August 2013

Content Search Web Part to roll up content in SharePoint 2013


SharePoint 2010 has a big limitation with Content Query Web Part to roll up content and we have to do good effort of work around as Content Query Web Part was limited to the Site Collection. In SharePoint 2010 we used the Content Query Web Part which helps us to see content instantly without waiting for the next crawl.

This drawback is eliminated in SharePoint 2013 using Content Search Web Part. Content Search Web part is available in the Web part>Content Roll Up>Content Search. This web part will allow you to create your own query easily and display the results the way.

Change Query in the Property Page will allow you to design your own query. The “Query Builder” has a nice UI that helps us to configure the query. “Switch to the Advanced Mode” in the “Query Builder” will provide more option to narrow down result.

A “Test Query” Option is available with the “Query Builder” which will provide a Preview of Result for whatever you configured.

Now the question is why we need Content Query Web Part in SharePoint 2013 since we are having Content Search Web part. To understand this we need to understand how this both web parts work. CSWP work based on the search index, made by Crawl. The result will be displayed is the data is crawled. CQWP does not depend on Crawl. Again this is less significant since as SharePoint 2013 supports continuous crawl. CSWP will not search minor versions whereas CQWP does.(I am not sure this is a bug and will be rectified later). From a design perspective CSWP no longer requires XSLT, HTML, or JavaScript.

14 August 2013

SharePoint 2013 Geo Location Field & Map

SharePoint 2013 Provide a new field type (column type) called Geo location. This field is used to enter the longitude and latitude data. SharePoint out Of the Box will provide an association to a Bing map to the entered Geo Location. A list Created with Geo Location field will also can have a Map View in which a map will be displayed aside the list with the pinned entered Geo location. When you hover the Geo Location in the list the corresponding location will be highlighted in the map.

The Site column contain a field called “Location” , But this field will not be the right thing to add for Geo Location. We cannot add Geo Location field using SharePoint 2013 UI.
Use the following code to create a Geo Location field to a List.

private static void CreateGeolocationField()
{
  // Replace site URL and List Title with Valid values.
  ClientContext context = new ClientContext("<site url>");
  List myList = context.Web.Lists.GetByTitle("list Title");
  myList.Fields.AddFieldAsXml("<Field Type='Geolocation' DisplayName='Location'/>", true,   AddFieldOptions.AddToAllContentTypes);
  myList.Update();
  context.ExecuteQuery();
}
 
You can also use power shell command for the same.
A map view of the list can be created using UI.

12 August 2013

SharePoint 2013 Device channels - Branding and Content based on Devices and Browsers

Device channels in SharePoint 2013 allow changing the look and feel depending on the browser or the device. This feature helps to implement corresponding Master Page or Page layout designed for the end browser or device.

Device Channels can be implemented only for the publishing sites, which make sense since on publishing sites only we can publish different master pages.

We have to create a “Device inclusion rule” to identify an end browser or Device. The Device inclusion rule that need to be included can be referred from the site “whatismyuseragent.com”.
To implement device channel navigate to Settings > Look And feel > Device Channel and Add a new entry. “Device inclusion rule” is the vital data here. Name, Alias and Active are other columns here once all this entries are added and saved you will get an option in the Master pages settings to select a new master page for the entry you just created.

We can choose to include or exclude portion of any page layout in a channel this will help for including or excluding content based on browser/devices.
Thus Device Channel is a significant feature in SharePoint 2013 that helps to render the appropriate look and fell and content based on browsers and devices.