從入口網路設定多面向搜尋結果 Web 範本

您可以根據 Dataverse 搜尋,檢視並搜尋入口網站上的知識文章附件。 若要這樣,您必須從入口網路設定多面向搜尋結果 Web 範本。

  1. 在入口網站管理網站地圖的 內容 區域中,選取 Web 範本
  2. 使用中 Web 範本 下拉式清單中,選取您的知識文章 Web 範本。
  3. Web 範本 頁面的 一般 索引標籤上,將下列程式碼片段加入至 來源 欄位。
                            {{#if relatedAttachments}}
                              {{#each relatedAttachments}}
                                  <li class="note-item">
                                  {{#if isImage}}
                                      <a id="kbattachment-{{entityID}}" href="javascript:downloadKbAttachmentFile('kbattachment-{{entityID}}', '{{title}}', {{fileSize}}, '{{fileType}}', '{{downloadBlockUrl}}', '{{initializeDownloadUrl}}')"><span class="glyphicon glyphicon-file" aria-hidden="true"></span>&nbsp;{{title}}</a>
                                  {{else}}
                                      <a id="kbattachment-{{entityID}}" title="{{title}}" href="javascript:downloadKbAttachmentFile('kbattachment-{{entityID}}', '{{title}}', {{fileSize}}, '{{fileType}}', '{{downloadBlockUrl}}', '{{initializeDownloadUrl}}')"><span class="glyphicon glyphicon-file" aria-hidden="true"></span>&nbsp;{{title}}</a>
                                  {{/if}}
                                  <p class="fragment text-muted">{{{fragment}}}</p>
                                  </li>
                              {{/each}}
                          {{/if}}
<script type="text/javascript">
      function downloadKbAttachmentFile(attachmentElementId, fileName, fileSize, mimeType, downloadBlockUrl, initializeUrl) {
                  // Download block API supports max 4MB block size
                  const blockSizeInBytes = 4096 * 1024;
                  const totalNumberOfBlocks = parseInt(fileSize / blockSizeInBytes + 1);
                  var fileContinuationToken = "";
                  var contentString = "";
                  var numberOfBlocksDownloaded = 0;
                  var blockNumberToContentMap = {};
                  function downloadBlockCallback(i, result) {
                      numberOfBlocksDownloaded++;
                      blockNumberToContentMap[i] = result;
                      if (numberOfBlocksDownloaded == totalNumberOfBlocks) {
                          for (var j = 0; j < totalNumberOfBlocks; j++) {
                              contentString += blockNumberToContentMap[j];
                          }
                          var isImage = mimeType.startsWith('image/');
                          const attachmentElement = document.getElementById(attachmentElementId);
                          if (isImage) {
                              const bodyByteString = atob(contentString);
                              const bodyBuffer = new ArrayBuffer(bodyByteString.length);
                              const bodyView = new Uint8Array(bodyBuffer);
                              for (var k = 0; k < bodyByteString.length; k++) {
                                  bodyView[k] = bodyByteString.charCodeAt(k);
                              }
                              var imageUrl = URL.createObjectURL(new Blob([bodyBuffer], { type: mimeType }));
                              attachmentElement.href = imageUrl;
                              attachmentElement.target = "_blank";
                          }
                          else {
                              const linkSource = 'data:' + mimeType + ';base64,' + contentString;
                              attachmentElement.href = linkSource;
                              attachmentElement.download = fileName;
                          }
                          attachmentElement.click();
                      }
                  }
                  shell.ajaxSafePost({
                      type: 'GET',
                      url: initializeUrl,
                      success: function (result) {
                          fileContinuationToken = encodeURIComponent(result);
                          for (var i = 0; i < totalNumberOfBlocks; i++) {
                              url = downloadBlockUrl + "&blockNumber=" + i + "&fileContinuationToken=" + fileContinuationToken + "&blockSize=" + blockSizeInBytes;
                              var x = downloadBlockCallback.bind(this,i);
                              shell.ajaxSafePost({
                                  type: 'GET',
                                  url: url,
                                  success: (result) => { x(result) }
                              });
                          }
                      }
                  });
              }
      </script>
  1. 選取 儲存

另請參閱

將檔案附件新增至知識文章
更新入口網站的知識文章附件
隨著知識庫文章顯示檔案附件

Hinweis

是否能請您告知您偏好的慣用文件語言? 請填寫問卷。 (請注意,本問卷為英文版)

完成問卷大約需要七分鐘。 本問卷將不會收集個人資料 (隱私權聲明)。