次の方法で共有


ポータルでファセット検索結果の 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. 保存 を選択します。

参照

ナレッジ記事にファイル添付を追加する
ポータルのナレッジ記事の添付ファイルを更新するナレッジ記事の添付ファイルを表示する