Content Search WebPart – SlideShow with LargePicture with up to 6 line mappings

In SharePoint Online, the Content Search Web Part allows you to view search results as a Slideshow.

Just add a Content Search Web Part to a page and select Slideshow from the control option.

SlideShow

The result looks like SlideShowRes

However there is an issue with the OOB SlideShow, if the results returned are less than the “Number of items to show” let’s say 2 results are returned, it still shows the bar for three items and show blank space when slideshow gets image 3.

To fix the issue, I used the blog link below

http://sp2013.blogspot.co.uk/2013/08/sharepoint-content-search-web-part.html

I created a copy of the Control_Slideshow from the display templates library (accessible from site settings> Master Pages and Layouts > Display Templates > Content Web Parts) and named it Control_NewsSlideshow and modified it as per the blog described above.

The Large Picture item allows to change mapping of managed properties up to 2 lines.
LargePictureProperties

If more managed properties need to be displayed on the picture, the item control needs to be amended.

Take a copy of the Large Picture (accessible from site settings> Master Pages and Layouts > Display Templates > Content Web Parts) item Item_LargePicture.html and modify it to allow it to cater for 6 lines

Rename the copy to Item_NewsSlider.

Edit the title property. The title will be visible when picking an item from the Content Search WebPart.

News Slider

Edit Line 8 to add the additional mapping properties to web part

From

<mso:ManagedPropertyMapping msdt:dt="string">'Picture URL'{Picture URL}:'PublishingImage;PictureURL;PictureThumbnailURL','Link URL'{Link URL}:'Path','Line 1'{Line 1}:'Title','Line 2'{Line 2}:'Description','SecondaryFileExtension','ContentTypeId'</mso:ManagedPropertyMapping>

To

<mso:ManagedPropertyMapping msdt:dt="string">'Picture URL'{Picture URL}:'PublishingImage;PictureURL;PictureThumbnailURL','Link URL'{Link URL}:'Path','Line 1'{Line 1}:'Title','Line 2'{Line 2}:'Description','Line 3'{Line 3}:'','Line 4'{Line 4}:'','Line 5'{Line 5}:'','Line 6'{Line 6}:'','SecondaryFileExtension','ContentTypeId'</mso:ManagedPropertyMapping>

After line 42  , add the additional lines rendering so that the values from the additional lines can be read to display.

var linkURL = $getItemValue(ctx, "Link URL");
linkURL.overrideValueRenderer($urlHtmlEncodeValueObject);

var line1 = $getItemValue(ctx, "Line 1");
var line2 = $getItemValue(ctx, "Line 2");
var line3 = $getItemValue(ctx, "Line 3");
var line4 = $getItemValue(ctx, "Line 4");
var line5 = $getItemValue(ctx, "Line 5");
var line6 = $getItemValue(ctx, "Line 6");

var pictureURL = $getItemValue(ctx, "Picture URL");
var pictureId = encodedId + "picture";
var pictureMarkup = Srch.ContentBySearch.getPictureMarkup(pictureURL, 468, 220, ctx.CurrentItem, "cbs-largePictureImg", line1, pictureId);

var containerId = encodedId + "container";
var pictureLinkId = encodedId + "pictureLink";
var pictureContainerId = encodedId + "pictureContainer";
var dataContainerId = encodedId + "dataContainer";
var dataContainerOverlayId = encodedId + "dataContainerOverlay";
var line1LinkId = encodedId + "line1Link";
var line1Id = encodedId + "line1";
var line2Id = encodedId + "line2";
var line3Id = encodedId + "line3";
var line4Id = encodedId + "line4";
var line5Id = encodedId + "line5";
var line6Id = encodedId + "line6";

Amend the html display to include the additional line properties

_#= line1 =#_

_#= line2 =#_
_#= line3 =#_
_#= line4 =#_
_#= line5 =#_
_#= line6 =#_

Selected the item News Slider will allow to map properties up to 6 lines.

Up_To_6_Lines_NewsSlider

The completed file Item_NewsSlider.html can be downloaded from
https://onedrive.live.com/redir?resid=DAD16970816E89BC!82395&authkey=!AARCZSF715Ps2qM&ithint=file%2chtml

The completed file Item_Control_NewsSlideshow.html can be downloaded from
https://onedrive.live.com/redir?resid=DAD16970816E89BC!82397&authkey=!AA419dpIenk0H0E&ithint=file%2chtml

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s