Add Content Search to a Site in Oracle Content Management
You can add content search to an Oracle Content Management site with a search page and search field.
To add content search to a site:
Add a Search Page to the Site
You can add a search page to a site and a Content List component to the search page.
Add the search page:
-
Add a page to the site and set it as a search page.
-
Add a Content List component to the search page.
-
Set Content Type to the page index content type created previously.
Add a Search Field to the Theme
To make a search field show on every page of a site, you can add the search field to the theme’s layout HTML page.
For example:
<div align="center">
<input id="searchonpage" type="text" size="30" placeholder="Search on page. . ."/>
</div>
-
Add the input field :
<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>
-
Add the JavaScript at the end of the HTML body.