機械翻訳について

Oracle Content Managementのサイトへのコンテンツ検索の追加

検索ページおよび検索フィールドを含むOracle Content Managementサイトにコンテンツ検索を追加できます。

サイトにコンテンツ検索を追加するには、次のステップを実行します:

  1. サイトへの検索ページの追加

  2. テーマへの検索フィールドの追加

サイトへの検索ページの追加

検索ページをサイトに追加し、コンテンツ・リスト・コンポーネントを検索ページに追加できます。

検索ページを追加します:

  1. ページをサイトに追加し、検索ページとして設定します。

  2. 検索ページにコンテンツ・リスト・コンポーネントを追加します。

  3. 「コンテンツ・タイプ」を以前に作成したページ・インデックスのコンテンツ・タイプに設定します。

テーマへの検索フィールドの追加

検索フィールドをサイトのすべてのページに表示するには、検索フィールドをテーマのレイアウトHTMLページに追加します。

たとえば:

<div align="center">
<input  id="searchonpage" type="text" size="30" placeholder="Search on page. . ."/>
</div>
  1. 入力フィールドを追加します :

    <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>
    
  2. HTML本文の最後にJavaScriptを追加します。