<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Display Templates Archives : Binary Bits</title>
	<atom:link href="https://blog.binarybits.net/tag/display-templates/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.binarybits.net/tag/display-templates/</link>
	<description>Bits &#38; Pieces - A blog by Kannan Balasubramanian</description>
	<lastBuildDate>Wed, 17 May 2017 07:52:49 +0000</lastBuildDate>
	<language>en-GB</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>File Icons in SharePoint Search Results using Display Template</title>
		<link>https://blog.binarybits.net/file-icons-sharepoint-search-results-using-display-template/</link>
					<comments>https://blog.binarybits.net/file-icons-sharepoint-search-results-using-display-template/#respond</comments>
		
		<dc:creator><![CDATA[Kannan]]></dc:creator>
		<pubDate>Mon, 11 Jul 2016 05:44:37 +0000</pubDate>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[SharePoint]]></category>
		<category><![CDATA[Display Templates]]></category>
		<category><![CDATA[SharePoint 2013]]></category>
		<category><![CDATA[SharePoint Search]]></category>
		<guid isPermaLink="false">https://blog.binarybits.net/?p=777</guid>

					<description><![CDATA[<p>In SharePoint 2013 search results, the icon for a file type like .msg, .txt shows up as .html icon. In SharePoint 2010 this was overcome by mapping the icon file type in DocIcon.xml at WFE Servers. But now since access to WFE servers are restricted in on-prem environment and no access in O-365 environment, the [&#8230;]</p>
<p>The post <a href="https://blog.binarybits.net/file-icons-sharepoint-search-results-using-display-template/">File Icons in SharePoint Search Results using Display Template</a> appeared first on <a href="https://blog.binarybits.net">Binary Bits</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In SharePoint 2013 search results, the icon for a file type like .msg, .txt shows up as .html icon.<br />
In SharePoint 2010 this was overcome by mapping the icon file type in DocIcon.xml at WFE Servers.</p>
<p>But now since access to WFE servers are restricted in on-prem environment and no access in O-365 environment, the only solution available is to do the following.</p>
<ol>
<li>Edit the existing display template (I use custom display template with results shown in table and following is based on that) or create a new template for existing for the following located at (SiteCollection/All Files/_catalogs/masterpage/Display Templates/Search) accessible by using SharePoint Designer.
<ol>
<li>xxxSearchTableResults.html</li>
<li>xxxSearchTableItem.html</li>
</ol>
</li>
<li>Add the following codes and it should show correct icons.</li>
</ol>
<p><strong>Search Results Display Template:</strong></p>
<pre class="lang:xhtml decode:true">&lt;div style="width:15px;display:table-cell;text-align:left;font-weight:bold;padding: 5px 0px 4px 10px;"&gt;                                       
&lt;/div&gt;</pre>
<p><strong>Search Item Display Template:</strong></p>
<pre class="lang:xhtml decode:true">&lt;div style="min-width:16px;max-width:16px;display: table-cell;white-space:nowrap;overflow:hidden;-ms-text-overflow:ellipsis;-o-text-overflow:ellipsis;text-overflow:ellipsis;"&gt;                                       
&lt;!--#_
 var extObj = new Object();
extObj["FileExtension"] = ctx.CurrentItem.FileExtension;
 var iconUrl = SP.Utilities.HttpUtility.htmlEncode(Srch.U.ensureAllowedProtocol(Srch.U.getIconUrlByFileExtension(extObj, null)));
if(ctx.CurrentItem.IsContainer)
iconUrl = "/_layouts/15/images/icdocset.gif";
if(ctx.CurrentItem.FileExtension === "msg")
iconUrl = "/_layouts/15/images/icmsg.gif";
//console.log(ctx.CurrentItem.FileExtension);
 _#--&gt;
&lt;img id="_#= $htmlEncode(id + Srch.U.Ids.icon) =#_" onload="this.style.display='inline'" src='_#= iconUrl =#_' /&gt;
 &lt;/div&gt;</pre>
<p><strong>Notes:</strong><br />
<em>ctx.CurrentItem.FileExtension</em> always return the file extension name which seems to match with the file name in the <em>/_layouts/15/images/</em> folder.</p>
<p>For example <strong>msg</strong> = ic<strong>msg</strong>.gif or ic<strong>msg</strong>.png</p>
<p>Once done, the search results will show-up as following</p>
<p><img decoding="async" class="alignnone size-full wp-image-781" src="https://blog.binarybits.net/wp-content/uploads/2016/07/Search-Icon.png" alt="Search-Icon" width="27" height="83" /></p>
<p>The post <a href="https://blog.binarybits.net/file-icons-sharepoint-search-results-using-display-template/">File Icons in SharePoint Search Results using Display Template</a> appeared first on <a href="https://blog.binarybits.net">Binary Bits</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.binarybits.net/file-icons-sharepoint-search-results-using-display-template/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>

<!--
Performance optimized by W3 Total Cache. Learn more: https://www.boldgrid.com/w3-total-cache/?utm_source=w3tc&utm_medium=footer_comment&utm_campaign=free_plugin

Page Caching using Disk: Enhanced 
Minified using Disk

Served from: blog.binarybits.net @ 2026-04-23 06:42:28 by W3 Total Cache
-->