Copied to clipboard

Flag this post as spam?

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


  • Moran 285 posts 934 karma points
    Apr 29, 2014 @ 16:24
    Moran
    0

    open search results in a new page

    Hi

    I am using ezSearch version 1.2 and I was wondering how can I render the search results in a different page.

    Thanks

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Apr 29, 2014 @ 16:27
    Matt Brailsford
    0

    Hi Moran,

    How do you mean?

    ezSearch comes with an example docType/template you can use, but if you have an existing docType/template you want to use, you can just copy the code from the example template file and add it to your own.

    Is that what you meant?

    Matt

  • Moran 285 posts 934 karma points
    Apr 30, 2014 @ 06:13
    Moran
    0

    Hi

    Sorry for the lat response, as of now I see that ezsearch is rendering the search results in the same page that the macro is placed, my question is how can I redirect the user, after he enters the search term and press "Enter", to a new page with only the search results in it.

     

  • Matt Brailsford 4125 posts 22222 karma points MVP 9x c-trib
    Apr 30, 2014 @ 12:29
    Matt Brailsford
    102

    Hi Moran,

    Ahh, ok

    Well ezSearch will respond to a querystring of ?q=yoursearchterm, so if you setup a search form on your other page, and have it send using GET to your ezSearch page, that should do the trick (if you like, you can configure the ezSearch macro to not show the search box too).

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

    Hope that helpers.

    Many thanks

    Matt

  • Moran 285 posts 934 karma points
    Apr 30, 2014 @ 13:09
    Moran
    0

    Thanks a lot :)

  • Simon 692 posts 1068 karma points
    Mar 12, 2015 @ 10:16
    Simon
    0

    Hi Matt,

    I am rendering the ezSearch form on master page, because I want it for every page. But Results are always showing underneath.

    Do you know how can I send the results to another page?

     

    Thank you.

    Kind Regards

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Mar 12, 2015 @ 10:38
    Dennis Aaen
    2

    Hi Simon,

    I am working on a project right now where we also used ezSearch form on master page, because we want it for every page. So what I did was added the searh field to the master page, and created a new document type for thesearch result page, e.g called SearchResult. So my input field look like this.

    form id="search-wrap" class="search-wrap" method="get" action="@rootNode.Children(x => x.DocumentTypeAlias == "Searchresults").First().Url()">
        <label for=" search-input" id="search-button" class="search-button">
         <span class="visuallyhidden">Search</span>
         </label>
         <input id="search-input" class="search-input" name="q" type="text" value="" placeholder="Search ..." autocomplete="off" />
    </form>

    And the root node variable is this, perhaps you will need to change it so it match your content structure.

    var rootNode = Model.Content.AncestorOrSelf(1);

    Remeber to change the document type alias so it match your case. 

    In the template for the new search result page I added the macro for the ezSearch, and added the different params, that I want to seach in, like this:

    <div class="container_12 main">
        @Umbraco.RenderMacro("ezSearch", new { rootContentNodeId = "", rootMediaNodeId = "null", indexType = "BOTH", searchFields = "header,teaser,bodyText,pageTitle,metaDescription,nodeName", previewFields = "bodyText,teaser,header", previewLength = "255", pageSize = "10", hideFromSearchField = "umbracoNaviHide", searchFormLocation = "NONE" })           
    </div>

    Hope this helps,

    /Dennis

  • Simon 692 posts 1068 karma points
    Mar 12, 2015 @ 10:53
    Simon
    0

    You're Awesome Deenis :)

    Thank you mate :)

    Cheers.

  • Simon 692 posts 1068 karma points
    Mar 12, 2015 @ 15:55
    Simon
    0

    Hi Dennis,

    How can I modify the code so that I can modify the pagination to have such as: Showing 1 - 11 of 43 search results ?

    Thank you Dennis.

    Kind Regards

  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Mar 12, 2015 @ 16:12
    Dennis Aaen
    0

    Hi Simon,

    I think that you can do it like this:

    Find this piece of code in the ezSearch.cshtml. probably in line 203.

    <div class="ezsearch-result-count">
        <p>@FormatHtml(GetDictionaryValue("[ezSearch] Results Range", "Showing results <strong>{0}</strong> of <strong>{1}</strong>."), startRecord, endRecord)</p>
    </div>

    Then you need to change it to this.

    <div class="ezsearch-result-count">
        <p>@FormatHtml(GetDictionaryValue("[ezSearch] Results Range", "Showing results <strong>{0}</strong> - <strong>{1}</strong> of <strong>{2}</strong>"), startRecord, endRecord, model.TotalResults)</p>
    </div>

    Hope this works for you.

    /Dennis

  • Simon 692 posts 1068 karma points
    Mar 13, 2015 @ 09:37
    Simon
    0

    Oh,

    I forgor that helper.

    Thank you Dennis. Also, I have changed the Resukts Dictionary in order to work as expected.

    Thank you once again.

    Cheers

Please Sign in or register to post replies

Write your reply to:

Draft