Oracle Content Managementのサイトへのコンテンツ検索の追加
検索ページおよび検索フィールドを含むOracle Content Managementサイトにコンテンツ検索を追加できます。
サイトにコンテンツ検索を追加するには、次のステップを実行します:
サイトへの検索ページの追加
検索ページをサイトに追加し、コンテンツ・リスト・コンポーネントを検索ページに追加できます。
検索ページを追加します:
-
ページをサイトに追加し、検索ページとして設定します。
-
検索ページにコンテンツ・リスト・コンポーネントを追加します。
-
「コンテンツ・タイプ」を以前に作成したページ・インデックスのコンテンツ・タイプに設定します。
テーマへの検索フィールドの追加
検索フィールドをサイトのすべてのページに表示するには、検索フィールドをテーマのレイアウトHTMLページに追加します。
たとえば:
<div align="center">
<input id="searchonpage" type="text" size="30" placeholder="Search on page. . ."/>
</div>
-
入力フィールドを追加します :
<script> // Get the search field element const node = document.getElementById('searchonpage'); // Get the search string from the url if it exists var params = (new URL(document.location)).searchParams; var defaultStr = params && params.get('default'); if (defaultStr) { if (defaultStr.lastIndexOf('*') === defaultStr.length - 1) { defaultStr = defaultStr.substring(0, defaultStr.length - 1); } // Display the search string in the search field node.value = defaultStr; } // When enter from the search field, go to the site search page with the search string node.addEventListener('keydown', function onEvent(event) { if (event.key === "Enter") { var inputElem = event.srcElement || event.target; var siteSearchPageUrl = 'search.html'; var searchUrl = SCSRenderAPI.getSitePrefix() + siteSearchPageUrl + '?contentType=indextype&default=' + inputElem.value + '*'; window.location = searchUrl; } }); </script>
-
HTML本文の最後にJavaScriptを追加します。