Copied to clipboard

Flag this post as spam?

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


  • Lars 66 posts 136 karma points
    Apr 30, 2015 @ 10:59
    Lars
    0

    Redirect ezsearch results

    Hi there

    I have installed exsearch and it works fine. I am able to redirect to redirect the user to a specific page for showing the results. My problem is that I want to show the results at a place on the "show-results" page which I control. Like if I want to show the results in the div: <div id="show-results"><!-- results from ezSearch here --> </div>.

    Does anyone know how to do that?

    /Lars

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Apr 30, 2015 @ 11:19
    Jan Skovgaard
    0

    Hi Lars

    You should be able to simply put the macro inside the div like this for instance

    <div id="show-results">
    @Umbraco.RenderMacro("ezSearch", new {rootContentNodeId = "1064"})
    </div>
    

    Hope this helps.

    /Jan

  • Lars 66 posts 136 karma points
    Apr 30, 2015 @ 11:34
    Lars
    0

    Hi Jan

    Thank you for a quick reply.

    You might be right but I am not quite sure about what you mean.

    1. In my master I put in the ezSearch Razor script by this code <div class="myHeaderClass">@Umbraco.RenderMacro("ezSearch")</div>

    2. In the form of the ezSearch I put in a action: <form action="/my_page_for_showing_results/" method="GET" class="ezsearch-form navbar-form" role="search">

    3. If I put in your fine piece of code must I then use the Id of "my_page_for_showing_search_results/" page where I want to show the results? I don't understand what new {rootContentNodeId = "1064"} does!

    /Lars

  • Lars 66 posts 136 karma points
    Apr 30, 2015 @ 11:57
    Lars
    0

    Hi Jan

    Thank you for a quick reply.

    You might be right but I am not quite sure about what you mean.

    1. In my master I put in the ezSearch Razor script by this code <div class="myHeaderClass">@Umbraco.RenderMacro("ezSearch")</div>

    2. In the form of the ezSearch I put in a action: <form action="/my_page_for_showing_results/" method="GET" class="ezsearch-form navbar-form" role="search">

    3. If I put in your fine piece of code must I then use the Id of "my_page_for_showing_search_results/" page where I want to show the results? I don't understand what new {rootContentNodeId = "1064"} does!

    /Lars

  • Tessa 20 posts 72 karma points
    Jul 28, 2015 @ 15:08
    Tessa
    100

    It looks like you want to separate the search input and button from the search results.

    Inside the div that you want the only the results to show, put this piece of code there.

    <div id="search-results">
        @Umbraco.RenderMacro("ezSearch", new { searchFormLocation = "NONE"})
    </div>
    

    Setting the variable "searchFormLocation" to "NONE" hides the search input and button fields from the macro and only displays the results.

    For the search field and button in your header, put something like this:

    <form action="/search" method="get">
        <input name="q" />
        <button type="submit" value="Search">Search</button>
    </form>
    

    Make sure the action points to the URL for where you're rendering your ezSearch macro. The name of the input field being "q" is important for the ezSearch macro to get textstring of the items searched.

    I hope this helps!

  • Lars 66 posts 136 karma points
    Jul 29, 2015 @ 09:20
    Lars
    0

    Hi Tessa

    Thank you for you reply. Your idea is fine and works for the top. My final solution was to make an extra parametre, "showResults", a boolean. I set it to false the search form is shown, but not the results. In the other macro the macro is reversed showing only the results. Settings of the parametre is hard-coded.

    Here is the code to show the results:

    if (showResults == true) {
         @RenderSummary(model)
         @RenderResultsRange(model)
         @RenderResults(model)
    
         if (model.TotalPages > 1)
         {
             @RenderPager(model)
         }
      }
    
      if (model.SearchFormLocation == "bottom" || model.SearchFormLocation == "both")
      {
         if (showResults == false) {
             @RenderForm(model)
         }
      }
    }
    
Please Sign in or register to post replies

Write your reply to:

Draft