結果類型以及用來在 SharePoint Server 中顯示搜尋結果的顯示範本Result types and display templates that are used to display search results in SharePoint Server

摘要:了解預設結果類型以及用來顯示搜尋結果的顯示範本。Summary: Learn about the default result types and display templates that are used to display search results.

SharePoint Server 包含許多執行協助使用者尋找所尋找的極工作的預設搜尋功能。但是您可能會想查看特定的方式,例如,顯示專屬於您的公司或商務資訊在搜尋結果。自訂搜尋結果外觀的方式與何種資訊它們包含、 您可以建立新的結果類型和顯示範本或變更現有的錯誤。本文不會說明如何您可以這麼做,但概述預設結果類型以及用來顯示搜尋結果的顯示範本。SharePoint Server includes many default search features that do a great job in helping users find what they're looking for. But you might want your search results to look a certain way, for example, display information that's specific to your company or business. To customize how search results look and what information they contain, you can create new result types and display templates or change existing ones. This article does not describe how you can do this, but gives an overview of the default result types and display templates that are used to display search results.

關於結果類型About result types

當您在 SharePoint 網站進行搜尋時,通常會傳回許多搜尋結果。根據預設,搜尋結果會有不同的顯示方式,讓您可以輕易分辨不同類型的搜尋結果。例如,只要瀏覽下圖,您就可以發現前兩個搜尋結果是 PowerPoint 簡報,第三個結果是 Word 文件等等。When you search for something on a SharePoint site, very often many search results are returned. By default, the search results are displayed differently so that you can easily differentiate between the different types of search results. For example, just by glancing at the image below you can see that the first two search results are PowerPoint presentations, the third result is a Word document, and so on.

根據結果類型來顯示的搜尋結果

若要顯示搜尋結果以不同方式類似,搜尋結果排序成結果類型。結果類型是自訂的搜尋結果的分類。例如,如果 Microsoft PowerPoint 簡報中找到的搜尋結果,搜尋結果是屬於Microsoft PowerPoint結果類型。如果 PDF 檔案中找到的搜尋結果,就將搜尋結果是屬於PDF結果類型。To display search results differently like this, search results are sorted into result types. A result type is a classification of a search result. For example, if a search result is found in a Microsoft PowerPoint presentation, the search result belongs to the Microsoft PowerPoint result type. If a search result is found in a PDF file, the search result belongs to the PDF result type.

下表顯示預設結果類型。The following table shows the default result types.

結果類型Result type 中找到的搜尋結果Search result found in
人員Person
本機人員結果結果來源The Local People Results result source
Microsoft AccessMicrosoft Access
Microsoft Access 檔案A Microsoft Access file
Microsoft ExcelMicrosoft Excel
Microsoft Excel 檔案A Microsoft Excel file
Microsoft OneNoteMicrosoft OneNote
Microsoft OneNote 檔案A Microsoft OneNote file
Microsoft PowerPointMicrosoft PowerPoint
Microsoft PowerPoint 檔案A Microsoft PowerPoint file
Microsoft PublisherMicrosoft Publisher
Microsoft Publisher 檔案A Microsoft Publisher file
Microsoft VisioMicrosoft Visio
Microsoft Visio 檔案A Microsoft Visio file
Microsoft WordMicrosoft Word
Microsoft Word 檔案A Microsoft Word file
討論Discussion
社群網站內的項目An entry within a community site
回覆Reply
電子郵件回覆A reply to an e-mail
電子郵件Email
電子郵件An e-mail
影像Image
影像An image file
PDFPDF
PDF 檔案A PDF file
文字Text
文字檔案A TXT file
影片Video
影片檔案A video file
XMLXML
XML 檔案An XML file
ZipZip
ZIP 檔案A ZIP file
SharePoint 部落格SharePoint Blog
SharePoint 部落格網站A SharePoint Blog site
SharePoint 社群SharePoint Community
SharePoint 社群網站A SharePoint Community Site
SharePoint 討論版SharePoint Discussion Board
SharePoint 討論版資料庫A SharePoint Discussion Board library
SharePoint 文件庫SharePoint Document Library
SharePoint 文件庫A SharePoint Document library
SharePoint 清單SharePoint List
SharePoint 清單A SharePoint list
SharePoint 微網誌貼文SharePoint MicroBlog Post
SharePoint 部落格網站內的部落格貼文A blog post within a SharePoint Blog Site
SharePoint 圖片庫SharePoint Picture Library
SharePoint 圖片庫A SharePoint Picture library
SharePoint 網站SharePoint site
SharePoint 網站A SharePoint site
SharePoint 調查SharePoint Survey
SharePoint 調查A SharePoint survey
SharePoint WikiSharePoint Wiki
SharePoint Enterprise Wiki 網站A SharePoint Enterprise Wiki Site
SharePoint 圖片庫清單項目SharePoint Picture Library List Item
SharePoint 圖片庫中的項目An item in a SharePoint picture library
SharePoint 清單項目SharePoint List Item
SharePoint 清單中的項目An item in a SharePoint list
網頁Webpage
外部網頁,例如 HTML 或 ASPX 頁面External web pages, for example HTML or ASPX pages
預設結果類型Default Result Type
其他結果類型涵蓋的任何項目,例如 Java 檔案、C++ 或 C#Anything not covered by the other result types, for example Java files, C++ or C#

結果類型和顯示範本如何彼此相連How result types and display templates are connected

在 SharePoint 搜尋中心] 中搜尋結果會顯示在搜尋結果網頁組件。若要控制搜尋結果的顯示方式,請使用兩種類型的顯示範本:In a SharePoint Search Center, search results are displayed in a Search Results Web Part. To control how the search results are displayed, two types of display templates are used:

  1. 項目顯示範本Item display template

  2. 動態顯示面板顯示範本Hover panel display template

顯示用來控制搜尋結果顯示方式的範本

項目顯示範本定義每筆結果的顯示方式。當使用者將滑鼠指標停留自訂的搜尋結果動態顯示面板顯示範本會顯示其他資訊。The item display template defines how each result is displayed. The hover panel display template shows additional information when a user hovers with the mouse pointer over a search result.

下圖顯示結果類型和顯示範本如何彼此相連。The following diagram shows how result types and display templates are connected.

結果類型與顯示範本如何彼此相連

  1. 每個結果類型參照一個項目顯示範本。Each result type refers to an item display template.

  2. 每個項目顯示範本包含以動態顯示面板顯示範本參照的變數。這個變數是var hoverUrlEach item display template contains a variable that refers to a hover panel display template. This variable is var hoverUrl.

下表顯示預設結果類型如何連接至項目顯示範本和動態顯示面板顯示範本。The following table shows how the default result types are connected to item display templates and hover panel display templates.

結果類型Result type 項目顯示範本標題顯示在使用者介面Item display template title as shown in the user interface 項目顯示範本檔案名稱主版頁面圖庫中所示Item display template file name as shown in the Master Page Gallery 動態顯示面板顯示範本檔案名稱主版頁面圖庫中所示Hover panel display template file name as shown in the Master Page Gallery
人員Person
人員項目People Item
Item_PersonItem_Person
Item_Person_HoverPanelItem_Person_HoverPanel
Microsoft AccessMicrosoft Access
Office 文件項目Office Document Item
Item_OfficeDocumentItem_OfficeDocument
Item_OfficeDocument_HoverPanelItem_OfficeDocument_HoverPanel
Microsoft ExcelMicrosoft Excel
Excel 項目Excel Item
Item_ExcelItem_Excel
Item_Excel_HoverPanelItem_Excel_HoverPanel
Microsoft OneNoteMicrosoft OneNote
OneNote 項目OneNote Item
Item_OneNoteItem_OneNote
Item_OneNote_HoverPanelItem_OneNote_HoverPanel
Microsoft PowerpointMicrosoft Powerpoint
PowerPoint 項目PowerPoint Item
Item_PowerPointItem_PowerPoint
Item_PowerPoint_HoverPanelItem_PowerPoint_HoverPanel
Microsoft PublisherMicrosoft Publisher
Office 文件項目Office Document Item
Item_OfficeDocumentItem_OfficeDocument
Item_OfficeDocument_HoverPanelItem_OfficeDocument_HoverPanel
Microsoft VisioMicrosoft Visio
Office 文件項目Office Document Item
Item_OfficeDocumentItem_OfficeDocument
Item_OfficeDocument_HoverPanelItem_OfficeDocument_HoverPanel
Microsoft WordMicrosoft Word
Word 項目Word Item
Item_WordItem_Word
Item_Word_HoverPanelItem_Word_HoverPanel
討論Discussion
討論Discussion
Item_DiscussionItem_Discussion
Item_Discussion_HoverPanelItem_Discussion_HoverPanel
回覆Reply
回覆項目Reply Item
Item_ReplyItem_Reply
Item_Reply_HoverPanelItem_Reply_HoverPanel
電子郵件Email
預設項目Default Item
Item_DefaultItem_Default
Item_Default_HoverPanelItem_Default_HoverPanel
影像Image
預設項目Default Item
Item_DefaultItem_Default
Item_Default_HoverPanelItem_Default_HoverPanel
PDFPDF
PDF 項目PDF Item
Item_PDFItem_PDF
Item_PDF_HoverPanelItem_PDF_HoverPanel
文字Text
預設項目Default Item
Item_DefaultItem_Default
Item_Default_HoverPanelItem_Default_HoverPanel
影片Video
影片項目Video Item
Item_VideoItem_Video
Item_Video_HoverPanelItem_Video_HoverPanel
XMLXML
預設項目Default Item
Item_DefaultItem_Default
Item_Default_HoverPanelItem_Default_HoverPanel
ZipZip
預設項目Default Item
Item_DefaultItem_Default
Item_Default_HoverPanelItem_Default_HoverPanel
SharePoint 部落格SharePoint Blog
預設項目Default Item
Item_DefaultItem_Default
Item_Default_HoverPanelItem_Default_HoverPanel
SharePoint 社群SharePoint Community
社群項目Community Item
Item_CommunityItem_Community
Item_Community_HoverPanelItem_Community_HoverPanel
SharePoint 討論版SharePoint Discussion Board
預設項目Default Item
Item_DefaultItem_Default
Item_Default_HoverPanelItem_Default_HoverPanel
SharePoint 文件庫SharePoint Document Library
預設項目Default Item
Item_DefaultItem_Default
Item_Default_HoverPanelItem_Default_HoverPanel
SharePoint 清單SharePoint List
預設項目Default Item
Item_DefaultItem_Default
Item_Default_HoverPanelItem_Default_HoverPanel
SharePoint 微網誌貼文SharePoint MicroBlog Post
預設項目Default Item
Item_DefaultItem_Default
Item_Default_HoverPanelItem_Default_HoverPanel
SharePoint 圖片庫SharePoint Picture Library
預設項目Default Item
Item_DefaultItem_Default
Item_Default_HoverPanelItem_Default_HoverPanel
SharePoint 網站SharePoint Site
網站項目Site Item
Item_SiteItem_Site
Item_Site_HoverPanelItem_Site_HoverPanel
SharePoint 調查SharePoint Survey
預設項目Default Item
Item_DefaultItem_Default
Item_Default_HoverPanelItem_Default_HoverPanel
SharePoint WikiSharePoint Wiki
預設項目Default Item
Item_DefaultItem_Default
Item_Default_HoverPanelItem_Default_HoverPanel
SharePoint 圖片庫清單項目SharePoint Picture Library List Item
圖片項目Picture Item
Item_PictureItem_Picture
Item_Picture_HoverPanelItem_Picture_HoverPanel
SharePoint 清單項目SharePoint List Item
預設項目Default Item
Item_DefaultItem_Default
Item_Default_HoverPanelItem_Default_HoverPanel
網頁Webpage
網頁項目Web Page Item
Item_WebPageItem_WebPage
Item_WebPage_HoverPanelItem_WebPage_HoverPanel
預設結果類型Default Result Type
預設項目Default Item
Item_DefaultItem_Default
Item_Default_HoverPanelItem_Default_HoverPanel

所有結果類型使用的一般顯示範本Common display templates that are used by all result types

除了上一節所列的顯示範本,有一些所有結果類型所使用的顯示範本。這些被呼叫一般顯示範本。一般顯示範本所參照的項目顯示範本和動態顯示面板顯示範本。下圖顯示如何參照。In addition to the display templates that are listed in the previous section, there are some display templates that are used by all result types. These are called common display templates. The common display templates are referred to from both the item display templates and the hover panel display template. The following diagram shows how they are referenced.

結果類型與所有顯示範本如何彼此相連

  1. 每個項目顯示範本參照通用項目本文的項目顯示範本。Reference 是非_#=ctx.RenderBody(ctx)=#_Each item display template refers to the Common Item Body item display template. The reference is _#=ctx.RenderBody(ctx)=#_.

  2. 每個動態顯示面板顯示範本包含三個一般動態顯示面板顯示範本的三個參照。參照彼此_#=ctx.RenderHeader(ctx)=#_,``_#=ctx.RenderBody(ctx)=#__#=ctx.RenderFooter(ctx)=#_Each hover panel display template contains three references to the three common hover panel display templates. The references are _#=ctx.RenderHeader(ctx)=#_, _#=ctx.RenderBody(ctx)=#_ and _#=ctx.RenderFooter(ctx)=#_.

下表顯示一般顯示範本。The following table shows the common display templates.

顯示使用者介面中顯示範本標題Display template title as shown in the user interface 顯示在主版頁面圖庫中所示的範本名稱Display template name as shown in the Master Page Gallery 描述Description
一般項目內文Common Item Body
Item_CommonItem_BodyItem_CommonItem_Body
在搜尋結果網頁組件的內文中顯示資訊。Displays information in the body of the Search Results Web Part.
一般動態顯示面板頁首Common Hover Panel Header
Item_CommonHoverPanelItem_CommonHoverPanel
在動態顯示面板的頁首中顯示資訊。Displays information in the header of the hover panel.
一般動態顯示面板Common Hover Panel
Item_CommonPanel_BodyItem_CommonPanel_Body
在動態顯示面板的內文中顯示資訊。Displays information in the body of the hover panel.
一般動態顯示面板動作Common Hover Panel Actions
Item_CommonHoverPanel_ActionsItem_CommonHoverPanel_Actions
在動態顯示面板的頁尾中顯示動作,例如編輯或傳送。Displays actions in the footer of the hover panel, such as Edit or Send.

對升級的結果使用的顯示範本Display template that is used for promoted results

您可以使用查詢規則來升級個別結果,讓它們顯示在靠近搜尋結果清單的頂端。顯示升級的結果時,會使用未與結果類型相連的特定項目顯示範本。因此,該範本會用來顯示所有升級的搜尋結果。此顯示範本不會參照動態顯示面板顯示範本。You can use query rules to promote individual results so that they appear towards the top of the search results list. The promoted results are displayed by using a specific item display template that is not connected to a result type. Therefore, it is used to display all search results that are promoted. This display template does not refer to a hover panel display template.

下表顯示對升級的結果使用的顯示範本。The following table shows the display template that is used for promoted results.

項目顯示範本標題Item display template title 項目顯示範本檔案名稱主版頁面圖庫中所示Item display template file name as shown in the Master Page Gallery 描述Description
首選項目Best Bet Item
Item_BestBetItem_BestBet
顯示使用查詢規則來升級的搜尋結果。Displays search results that are promoted by using query rules.

另請參閱See also

概念Concepts

在 SharePoint Server 中自訂搜尋結果類型Customize search result types in SharePoint Server

在 SharePoint Server 中管理搜尋中心Manage the Search Center in SharePoint Server

在 SharePoint Server 中管理查詢規則Manage query rules in SharePoint Server

在 SharePoint Server 中顯示範本參考Display template reference in SharePoint Server