Copied to clipboard

Flag this post as spam?

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


  • mizzle 90 posts 325 karma points
    Jun 10, 2021 @ 13:46
    mizzle
    0

    Umbraco 6 search alternative to Umbraco.ContentQuery.Search

    I need to filter a foreach loop of items according to a search box submission. I've looked for a way to do this on an Umbraco 6 site using webforms, but I can't find anything that lets me do what I want. I've only found things like XSLT Search, which won't let me keep the page and layout I need to retain for the search and only adjust the results.

    I have code from an Umbraco 8 website that does the exact thing I need, but the critical part of the code (Umbraco.ContentQuery.Search) throws an error. I assume it doesn't exist in this older version of Umbraco.

    Is there an alternative to this, or some code that does a similar thing?

  • shekhar sharma 22 posts 110 karma points
    Jun 10, 2021 @ 14:07
    shekhar sharma
    0

    Hello Mizzle ,

    I am not sure. But you can try Linq (Custom Controller )for content filtration instead of (Umbraco.ContentQuery.Search ). This is not the best recommended but for quick solution you can try to fetch the record in controller and filter you result.

    Thanks,

    Shekhar

  • mizzle 90 posts 325 karma points
    Jun 10, 2021 @ 14:36
    mizzle
    0

    Sorry, but I don't really know what to do with that. Do you have an example of what the code would look like if I tried using the Linq solution in a similar way as the Umbraco.ContentQuery.Search line of code?

    For comparison, the latter in my Umbraco 8 code looks like

                var searchTerm = string.Empty;
                var noResultsMsg = "No results found.";
                searchTerm = string.IsNullOrEmpty(Request["query"]) ? string.Empty : Request["query"];
                var results = Umbraco.ContentQuery.Search(searchTerm, String.Empty, "ExternalIndex");
    

    And then I would foreach through the "results" and it would match up items with whatever the search query might have been.

Please Sign in or register to post replies

Write your reply to:

Draft