如何將自訂動作新增至 SharePoint Server 中的動態顯示面板How to add a custom action to the hover panel in SharePoint Server

摘要:了解如何將自訂動作新增至 SharePoint Server 中的動態顯示面板。Summary: Learn how to add a custom action to the hover panel in SharePoint Server.

如何從 SharePoint Server 中的動態顯示面板中的自訂受管理屬性的值,在我們顯示您如何在動態顯示面板中顯示自訂受管理屬性的值。本文中您將了解:In How to display values from custom managed properties in the hover panel in SharePoint Server, we showed you how to display values from custom managed properties in the hover panel. In this article you'll learn:

什麼是動態顯示面板動作?What is a hover panel action?

我們查看如何將自訂動作新增至動態顯示面板之前,請確定一下我們知道什麼是巨集指令。Before we look at how to add a custom action to a hover panel, let's make sure we know what an action is.

在動態顯示面板的底端有一些呼叫動作的連結。當我們選擇其中一個時,就會發生的某個項目。例如,在我們搜尋中心案例中,當我們選擇 「 傳送 」At the bottom of the hover panel there are some links that are called actions . When we choose one of these, something will occur. For example, in our Search Center scenario, when we choose "SEND"

傳送

會開啟電子郵件訊息與清單項目的連結。an email message with a link to the list item will open.

新郵件

若要讓我們訪客可從搜尋結果中的某個項目執行而不需要保留搜尋結果] 頁面上,我們可以新增自訂動作。To enable our visitors to do something with the search results, without having to leave the search results page, we can add a custom action.

在搜尋中心案例中,我們想要新增自訂動作所開啟的已發佈的文章。例如,對於搜尋結果 」 自訂搜尋結果類型 in SharePoint Server",我們想要新增動作可開啟此連結:<需要 fwlink 吗?http://technet.microsoft.com/en-us/library/dn135239.aspx>In our Search Center scenario, we wanted to add a custom action that opens the published article. For example, for the search result "Customize search result types in SharePoint Server", we wanted to add an action that opens this link:<need fwlink? http://technet.microsoft.com/en-us/library/dn135239.aspx>

如何新增動作至動態顯示面板How to add an action to the hover panel

我們清單中發佈的文章、 時要發行的文件的 URL 新增至清單項目。螢幕擷取畫面下方顯示內容版本 URL 」 上的 [網站] 欄中如何維護文章"自訂搜尋結果類型 in SharePoint Server"的 URL。In our lists, when an article is published, the URL to the published article is added to the list item. The screen shot below shows how the URL to the article "Customize search result types in SharePoint Server" is maintained in the site column "Content Release URL".

清單項目新增動作

因為此 URL 會保留在清單中,我們可以新增自訂動作將會開啟連結動態顯示面板。Because this URL is maintained in the list, we can add a custom action to the hover panel that will open the link.

如何從 SharePoint Server 中的動態顯示面板中的自訂受管理屬性的值顯示在動態顯示面板動作所Item_Common_HoverPanel_Actions顯示範本的呈現方式。因此,若要新增的自訂動作,您必須編輯此檔案。How to display values from custom managed properties in the hover panel in SharePoint Server showed how the hover panel actions are rendered by the Item_Common_HoverPanel_Actions display template. So, to add a custom action, you have to edit this file.

但是,類似什麼我們進行了我們在動態顯示面板來新增自訂屬性時,您已新增想要使用您的項目顯示範本的自訂動作的 managed 的屬性。But, similar to what we did when we added a custom property to the hover panel, you have to add the managed property that you want to use in your custom action to the item display template.

是否混淆吗?這並不容易。若要了解如何所連接的事項 while 延長。開始吧透過它逐步說明。Confused? Well, this is not easy. It takes a while to understand how things were connected. Let's go through it step-by-step.

若要將自訂動作新增到動態顯示面板的步驟如下:Here are the steps to add a custom action to the hover panel:

  1. 尋找您想要使用的網站欄的 managed 的屬性名稱。如何顯示搜尋結果-選項 1 in SharePoint Server 中的自訂受管理屬性的值會顯示如何執行這項作業。Find the managed property name of the site column that you want to use. How to display values from custom managed properties in search results - option 1 in SharePoint Server showed how to do this.

  2. 在對應的網路磁碟機中開啟項目顯示範本。在項目ManagedPropertyMapping標籤中顯示範本、 新增自訂的受管理的屬性使用下列語法:In your mapped network drive, open an item display template. In the item display template, in the ManagedPropertyMapping tag, use the following syntax to add the custom managed property:

    '<Current item property name>':<Managed property name>'
    

    在搜尋中心案例中,我們加入我們想要使用的TechNet 內容顯示範本的自訂屬性。In our Search Center scenario, we added the custom property we wanted to use to the TechNet content display template.

    已新增 MP

  3. 注意

    不執行此步驟設定若您使用 SharePoint Online。You don't have do this step if you are using SharePoint Online.

    移至 [網站設定 --> 搜尋結果類型。請注意屬性同步處理通知會顯示。Go to Site settings --> Search Result Types. Notice that a Property Sync alert is displayed.

    屬性同步處理警示

    顯示此警示是因為我們已新增新的 managed 的屬性 (什麼我們並未在步驟 2) 項目顯示範本。若要以新加入的 managed 屬性更新結果類型,選擇 [更新]。This alert is displayed because we have added a new managed property to an item display template (what we did in step 2). To update the result types with the newly added managed properties, choose Update.

    已更新 MP

    重要

    如果您不執行更新,新加入的 managed 的屬性將不會顯示在動態顯示面板。If you don't do the update, the newly added managed properties won't display in your hover panel.

  4. 開啟Item_Common_HoverPanel_Actions顯示範本。請參閱預設動作會建立和使用 JavaScript 及 HTML 新增您的自訂動作的方式。Open the Item_Common_HoverPanel_Actions display template. See how the default actions are created, and use JavaScript and HTML to add your custom action.

    在搜尋中心案例中,我們已經討論過如何在開啟的動作 ( #= editHmtl = # ) 所建立。根據所,我們建立新的動作: #= viewHtml = #。下列螢幕擷取畫面顯示我們進行了。In our Search Center scenario, we looked at how the OPEN action ( #= editHmtl =# ) is created. Based on that, we created a new action: #= viewHtml =#. The following screen shot shows what we did.

    已新增動作

    透過新的搜尋並停留自訂的搜尋結果,我們看到我們新的自訂動作的顯示。好 !By doing a new search and hovering over a search result, we saw that our new custom action was displayed. Nice!

    已顯示新動作

現在您知道如何變更搜尋結果的顯示的方式有的一點我們應該查看,且這是您可以在方式變更顯示在搜尋方塊網頁組件中的文字。So now that you know how to change the way your search results are displayed, there is one more thing we should look at, and that is how you can change the text that is displayed in the Search Box Web Part.

本系列中的下一篇文章Next article in this series

如何變更 SharePoint Server 中搜尋方塊網頁組件中顯示的文字How to change the text that is displayed in the Search Box Web Part in SharePoint Server