Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Hong 66 posts 228 karma points
    Dec 26, 2017 @ 22:57
    Hong
    0

    Why do ezSearch results show json code?

    I added ezSearch with the following code:

    @Umbraco.RenderMacro("ezSearch", new {rootContentNodeId="1094", rootMediaNodeId="", indexType="BOTH", searchFields="", previewFields="", previewLength="", pageSize="100", hideFromSearchField="", searchFormLocation=""})
    

    The search results show something like json code as following: enter image description here

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    Dec 27, 2017 @ 07:25
    David Brendel
    101

    Hi Hong,

    seems to me that you use the Grid on the page with the json search result. Grid data is saved as json and thus the rendering is also in Json.

    You can convert it to display better results.

    That's a nice sample how to do it: https://gist.github.com/abjerner/bdd89e0788d274ec5a33

    Regards David

  • Hong 66 posts 228 karma points
    Dec 27, 2017 @ 16:32
    Hong
    0

    Thank you for the tip, David.

    I just followed the instructions to create a new search page. The template of Content Page is the following:

    @inherits Umbraco.Web.Mvc.UmbracoTemplatePage<ContentModels.ContentPage>
    @using ContentModels = Umbraco.Web.PublishedContentModels;
    @{
        Layout = "Master.cshtml";
    }
    
    @Html.Partial("~/Views/Partials/SectionHeader.cshtml")
    
    <section class="section">
    
        <div class="container">
    
            <div class="col-md-3">
                <nav class="nav-bar nav-bar--list">
                    @Html.Partial("~/Views/Partials/Navigation/SubNavigation.cshtml")
                </nav>
            </div>
    
            <div class="col-md-9">
                <article>
                    @Html.GetGridHtml(Model.Content, "bodyText", "bootstrap3-fluid")
                </article>
            </div>
        </div>
        @Umbraco.RenderMacro("ezSearch", new {rootContentNodeId="1094", rootMediaNodeId="", indexType="BOTH", searchFields="", previewFields="", previewLength="", pageSize="100", hideFromSearchField="", searchFormLocation="TOP"})
    </section>
    

    I am new to Umbraco. I do not know where the grid is.

  • Alex Skrypnyk 6175 posts 24186 karma points MVP 8x admin c-trib
    Dec 27, 2017 @ 18:31
    Alex Skrypnyk
    1

    Hi Hong

    You have to add classes in a way that was described in the great article that David provided you your solution.

    These classes are indexing grid data in a needed way, so with that code, your search functionality should work in a proper way.

    Thanks,

    Alex

  • Hong 66 posts 228 karma points
    Dec 28, 2017 @ 02:30
    Hong
    0

    Thank you for the clarification, Alex. I think that I misunderstood the problem. I thought ezSearch was displaying something by mistake. Per your tips, it seems that ez Search was getting data in wrong formats, and the data need to be processed before they are fed to ezSearch.

  • Hong 66 posts 228 karma points
    Dec 30, 2017 @ 16:35
    Hong
    0

    I installed NuGet package Skybrud.Umbraco.GridData, added the classes as shown in the sample, made sure the ExamineIndexer initialization code is executed at the startup, but unfortunately, OnExamineGatheringNodeData is never invoked. Now, instead of displaying json code, the search results display the following:

    Skybrud.Umbraco.GridData.GridDataModel

Please Sign in or register to post replies

Write your reply to:

Draft