Displaying Most Searched Items on SharePoint 2013

Home / Blog / Displaying Most Searched Items on SharePoint 2013

Displaying Most Searched Items on SharePoint 2013

My topic is “How to show list of most searched items, by the users” on Microsoft SharePoint 2013 Enterprise Server Edition.

I came upon this requirement for one of our projects, the need was to display list of most searched items from Microsoft SharePoint 2013 list. The need was to sort is on the basis of search logs, the expectation was that those items should appear with the trend of most searched items on top.

So did some research to understand whether there is anything readily available within Microsoft SharePoint 2013 and eureka I found one! It’s one of the Content by Search Web Part – known as Popular Items Web Part.

The Content by Search Web Part (CSWP) is a new Web Part available on Microsoft SharePoint 2013 Enterprise Server Edition. In previous versions of Microsoft SharePoint, one would roll up the SharePoint content using the Content by Query Web Part (CQWP) from within the current site collection. The CSWP does not replace the CQWP but is an additional Web Part that enables you to display rolled up Microsoft SharePoint content from across the farm using the search result.

There are 5-6 Web Parts under this category and “Popular Items” is one of them. This Web Part will show items that have been recently viewed by many users. When you add it to the page, this Web Part will show items from the current site. You can change this setting to show items from another site or list by editing the Web Part and changing its search criteria. You can also customize how items are sorted. As new content is discovered by search, this Web Part will display an updated list of items each time the page is viewed.

Let’s have look at how Popular Items Web Part behaves. Assume that you have FAQs list created and you want to display list of FAQs on home page of your site with a trend that mostly searched FAQs should appear on top.

The solution is Go to home page of your SharePoint site → Edit Page → Add webpart → From Search-Driven Content section → Select Popular Items Webpart

Sharepoint blog

Utilizing Edit Web Part Properties to configure Popular Items Web Part to display most searched FAQs items

From Search Criteria section click on Change Query →in the Restrict by app section select “Specify a URL” option → enter URL of FAQs list → in Restrict by content type section select Item (this is to restrict list forms or list pages to appear in the result) → save the query

sharepoint blog

Once you save the query you can decide on how the items should be displayed on the page. Examples are as below:

  • An Enterprise Intranet Portal – Where you can display list of most searched documents with specific metadata associated with it like department name, author, this can be achieved by using existing templates and creating managed properties for the metadata to be shown
  • An E-commerce Portal - Then it will help you to display list of mobiles brands in tabular format with product specifications
  • A Hotel Search Portal – The need may be to display list of hotels in specific town. It can be achieved by using existing control & item templates or you can custom design using existing templates.

 

Existing Control Templates – List, List with paging, Slide Show, Top Report Result

sharepoint report

Existing Item Templates:

  1. Diagnostic
  2. Large picture
  3. Picture on left, 3 lines on right
  4. Picture on Top, 3 lines on bottom
  5. Recommended items
  6. Two lines
  7. Video

sharepoint form

With 2-3 lines templates, one can decide on what column property to be displayed in the result. By default it considers Title of the item.

Note: We need to ensure to run full crawl, create a managed property for the column, which you want to display in search result and then again run full crawl.

In our specific case, I created managed property for Answer column named FAQAnswer which I will be selecting as 2nd line.
sharepoint form

And once done, please save the settings and this is how FAQ items will appear

 

sharepoint FAQ

Custom Display Template

With existing templates, when you click on Search result item it will redirect you to item display form. Considering our requirement, we wanted to open that display form in popup page so that context of home page will not be lost. So we had to create custom display templates, to do so I followed below steps

Open your portal in SharePoint Designer  →  All site content  →  _Catalogs  →  masterpage  →  Display Template  →  Content Web Parts  →  Copy “Control_ListWithPaging.html” and paste in same location  →  rename newly copied file to “FAQs_ListWithPaging.html”  →  Refresh the folder and its respective JS file will get created automatically  →  Check out and edit new html template  →

Update the title section to <title>FAQs List with Paging</title>

Add below code after “<div id="Control_ListWithPaging"><!--#_”

ctx.OnPostRender = [];
ctx.OnPostRender.push(function(){
$('ul.faq a').click(function() {
var options = {
url: $(this).attr('href'),
title: 'FAQs',
width: 600,
height: 500,
};
SP.UI.ModalDialog.showModalDialog(options);
return false;
});
});

Replace “ _#= ctx.RenderGroups(ctx) =#_ </ul>”
</ul>
<ul class="faq">
_#= ctx.RenderGroups(ctx) =#_
</ul>

Check in and publish the file.

 

Recently Changed Items Web Part

This is another Web Part from CSWP category, earlier in Microsoft SharePoint 2010 version, we used to display documents/ items from particular list with sort by modified column but there was no way to show documents/ items from all the list/ libraries which are recently changed at one place. This Web Part in Microsoft SharePoint 2013 gives us that facility.

This Web Part will show items that have been modified recently. This can help site users track the latest activity on a site or a library. When you add it to the page, this Web Part will show items from the current site. You can change this setting to show items from another site or list by editing the Web Part and changing its search criteria. As new content is discovered by search, this Web Part will display an updated list of items each time the page is viewed.

sharepoint admin

Hope this is helpful. Please feel free to reach me on sarvesh.shinde@itcube.net for any questions.

 

Leave a Reply

Your email address will not be published. Required fields are marked *