5

I'm using contents web parts to get documents from specific document library.

And I already customized Item_Default.html in order to add lines and show discriptions next to Managed Properties.

Now the contents web parts looks like this.

=========================

Title

Last Modified Date [LastModifiedTime]

Editor [EditorOWSUSER]

All access [ViewsLifeTime] Recent Access [ViewsLast3Days] 

=========================

However, what I really wanted to do is to put picture on the left side....(and lines on the right side)

That's why at first, I tried to customize Item_Picture3lines.html of contents web parts display template. But I gave up customizing to show discriptions next to Managed Properties....

Does anybody know how to customize search template to show picture with search results like what i want?

Or anybody know how to customize Item_Picture3lines.html to put strings/discriptions of Managed properties?

Here is that template I customized and renamed Item_Custom.html based on Item_Default.html.

I'm Japanese so there are some Japanese words in the template...sorry

 Blockquote

<html xmlns:mso="urn:schemas-microsoft-com:office:office" xmlns:msdt="uuid:C2F41010-65B3-11d1-A29F-00AA00C14882"> 
<head>
<title>Customized Template</title>

<!--[if gte mso 9]><xml>
<mso:CustomDocumentProperties>
<mso:TemplateHidden msdt:dt="string">0</mso:TemplateHidden>
<mso:MasterPageDescription msdt:dt="string">This shows Title, Last Modified Date, Editor,  All access and recent access for document. </mso:MasterPageDescription>

<mso:ContentTypeId msdt:dt="string">0x0101002039C03B61C64EC4A04F5361F385106603</mso:ContentTypeId>
<mso:TargetControlType msdt:dt="string">;#SearchResults;#Content Web Parts;#</mso:TargetControlType>
<mso:HtmlDesignAssociated msdt:dt="string">1</mso:HtmlDesignAssociated>

<mso:ManagedPropertyMapping msdt:dt="string">'Title':'Title', 'EditorOWSUSER':EditorOWSUSER', 'LastModifiedTime:'LastModifiedTime', 'ViewsLifeTime':'ViewsLifeTime', 'ViewsLast3Days':'ViewsLast3Days','SecondaryFileExtension','ContentTypeId'
</mso:ManagedPropertyMapping>
<mso:HtmlDesignStatusAndPreview msdt:dt="string">https://[URL]/_catalogs/masterpage/Display Templates/Search/Item_Custom.html, 正常に変換されました。</mso:HtmlDesignStatusAndPreview>
<mso:HtmlDesignConversionSucceeded msdt:dt="string">True</mso:HtmlDesignConversionSucceeded>
<mso:CrawlerXSLFile msdt:dt="string"></mso:CrawlerXSLFile>
<mso:HtmlDesignPreviewUrl msdt:dt="string"></mso:HtmlDesignPreviewUrl>
</mso:CustomDocumentProperties>
</xml><![endif]-->
</head>
<body>
    <div id="Item_Custom">

<!--#_ 

    //Get Title
    var title = ctx.CurrentItem.Title; 
    var titleHtml = String.format('<a href="{0}" title="{1}" >{2}</a>', $urlHtmlEncode(ctx.CurrentItem.Path), $htmlEncode(title), $htmlEncode(title));

    //Get Editor
    var editorHtml = "";
    if (!$isEmptyString(ctx.CurrentItem.EditorOWSUSER)){
        var editorIdentifiers = ctx.CurrentItem.EditorOWSUSER.split(" | ");
             if(!$isNull(editorIdentifiers[1]))
             {
                 editorHtml = "Editor " + editorIdentifiers[1];
             }
    };


    //Get Last ModifiedTime
    var lastModifiedTime = ctx.CurrentItem.LastModifiedTime;
    var lastModifiedTimeHtml = "Last Modifed Date " + lastModifiedTime.getFullYear() + "年" + (lastModifiedTime.getMonth() + 1) + "月" + lastModifiedTime.getDate() +"日";

    //Get ViesLifeTime
    var ViewsLifeTime = ctx.CurrentItem.ViewsLifeTime;
    var ViewsLifeTimeHtml = " All access " + ViewsLifeTime;


    //Get ViewsLast3Days
    var ViewsLast3Days = ctx.CurrentItem.ViewsLast3Days;
    var ViewsLast3DaysHtml = " Recent Access (" + ViewsLast3Days + " )";

_#-->




<h3 class="ms-srch-ellipsis">_#=titleHtml=#_</h3><!-- Title -->
<div>    <span>_#=editorHtml=#_</span><!-- Editor --><br>
  <span>_#=lastModifiedTimeHtml=#_</span><!-- Last Modified Date --><br>
         <span>_#=ViewsLifeTimeHtml=#_</span><!-- All access -->
         <span>_#=ViewsLast3DaysHtml=#_</span><!-- Recent access -->
</div>


<!--#_ 
        if(!$isNull(ctx.CurrentItem) && !$isNull(ctx.ClientControl)){
            var id = ctx.ClientControl.get_nextUniqueId();
            var itemId = id + Srch.U.Ids.item;
   var hoverId = id + Srch.U.Ids.hover;
   var hoverUrl = "~sitecollection/_catalogs/masterpage/Display Templates/Search/Item_Default_HoverPanel.js";
            $setResultItem(itemId, ctx.CurrentItem);
   if(ctx.CurrentItem.IsContainer){
    ctx.CurrentItem.csr_Icon = Srch.U.getFolderIconUrl();
   }
   ctx.currentItem_ShowHoverPanelCallback = Srch.U.getShowHoverPanelCallback(itemId, hoverId, hoverUrl);
            ctx.currentItem_HideHoverPanelCallback = Srch.U.getHideHoverPanelCallback();
_#-->
            <div id="_#= $htmlEncode(itemId) =#_" name="Item" data-displaytemplate="DefaultItem" class="ms-srch-item" onmouseover="_#= ctx.currentItem_ShowHoverPanelCallback =#_" onmouseout="_#= ctx.currentItem_HideHoverPanelCallback =#_">
    _#=ctx.RenderBody(ctx)=#_
                <div id="_#= $htmlEncode(hoverId) =#_" class="ms-srch-hover-outerContainer"></div>
            </div>
<!--#_ 
        } 
_#-->
    </div>
</body>
</html>
0

You can fetch it from anywhere, but make sure you do a full crawl and make a managed propety from Search. So you can fetch the value using that property as below.

<span ><img src="_#= ctx.CurrentItem.ProfilePhoto =#_" height="150px" width="150px" /></span><br/><br/>

ProfilePhoto is the Managed property you create in search mapping to the column where your link is in the document Library. use this property and you will get Photo.

0

Are you trying to add static pictures or you want this pictures to be fetched from somewhere, I had my pictures uploaded in a list please check the way I have done it.

<span ><img src="_#= ctx.CurrentItem.ProfilePhoto =#_" height="150px" width="150px" /></span><br/><br/>

If you are using any specific image you can replace the url in "src". Make sure you have your image uploaded in the SharePoint Library of the current site.

  • Hi Akarsh Thank you for your comment. If this is possible, I want fetch pictures from document library column. – Miki Sakai Dec 12 '14 at 6:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.