Gravatar for nimishmis@yahoo.co.in

Question by nimishmis, Apr 16, 2015 12:07 PM

Coveo Enterprises Search 7.0+Coveo for Sitecore

Hi We are using Coveo for Sitecore 2015 April release with Sitecore7.5.We are using Coveo JS framework for Search.When we search Coveo Console results are coming.But we search in SearchBox results are not coming.

Below is the implimentation.

<%@ Control Language="c#" AutoEventWireup="true" TargetSchema="http://schemas.microsoft.com/intellisense/ie5" %>

<style type="text/css">
    #searchbox.CoveoSearchInterface {
        min-height: inherit;
    }
</style>

<sc:sublayout id="slSearchResources" runat="server" path="~/Sample/Sample/Sample/Search/Searchbox.ascx" />

<script type="text/javascript">
    var headerSearchPage = "<%=abc.DomainContext.Site.SearchPagePath%>"
    var pathField = "<%= Coveo.UI.SitecoreUtilities.ToCoveoFieldName("_Path") %>";
    var languageField = "<%= Coveo.UI.SitecoreUtilities.ToCoveoFieldName("language") %>";
    var currentLang = "<%= opq.GetContextLanguage() %>";

    $(function () {

        Coveo.Rest.SearchEndpoint.endpoints.default = new Coveo.Rest.SearchEndpoint({
            restUri: "/Coveo/Rest/",
            useJsonp: true
        });

        var searchInterface = $("#searchbox");
        searchInterface.on("afterInitialization", function () {
            searchInterface.on("newQuery", function (e, args) {

                var currentKeyword = searchInterface.coveo("state", "q");
                if (currentKeyword != "") {
                    window.location.href = headerSearchPage + "#q=" + encodeURIComponent(currentKeyword)
                }
            })
        })

        $('#searchbox').coveo('init', {
            SearchInterface: {
                autoTriggerQuery: false,
                hideUntilFirstQuery: false,
                enableHistory: false
            },
            TopFieldSuggestions: {
                queryOverride: pathField + "=nkl7896546788" + "  AND  " + languageField + "=" + nkl
            }
        });
    });
</script>

<div id="searchbox" class="search-box CoveoSearchInterface">
    <span class="CoveoTopFieldSuggestions"
        data-field="<%= Coveo.UI.SitecoreUtilities.ToCoveoFieldName("Auto Suggestion Keyword") %>"
        data-header-title="Suggested Queries"></span>

    <div class="CoveoSearchBox" data-activate-omnibox="true"></div>
</div>

<script type="text/javascript">
    $(document).ready(function () {
        $("#searchbox :text").attr("placeholder", "<%= Sitecore.Globalization.Translate.Text("Search")%>");
        $("#searchbox :text").attr("maxlength", "250");

        $("#searchbox :text").keydown(function (event) {
            if (event.keyCode == 13) {                
                var selText= $("#searchbox >div.CoveoSearchBox >div >div.coveo-omnibox >div.coveo-omnibox-section").find('.coveo-omnibox-selected').text();
                if (selText.length != 0)
                {
                    $("#searchbox :text").val($.trim(selText));
                }
                $("#searchbox").find('.CoveoSearchButton').click();
            }
        });

        $('#searchbox :text').blur(function(){
            setTimeout(function(){
                $("#searchbox").find('.coveo-omnibox').css('display', 'none');
            }, 500);
        });
    });

</script>
Gravatar for jflheureux@coveo.com

Comment by Jean-François L'Heureux, Apr 16, 2015 2:01 PM

Do you still have the errors reported in the following question? : https://answers.coveo.com/questions/2986/cove30-for-sitecore

If you do, we should resolve them before working on this question.

0 Reply
Ask a question