コンテンツ検索を検索ページおよび検索フィールドとともに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>
JavaScriptをHTMLボディの最後に追加します。