Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
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?
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.
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.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted