Hi Huw, thanks for getting back to me. Sorry I should've included at the time but I'm having an issue on Umbraco Cloud logs where the current days logs never load. Error message in logs: error CS0103: The name publishedContentQuery does not exist in the current context
Does anyone know how I can exclude certain pages from this search? I've copied the above which is great :) however it has content nodes like my site settings node and certain content nodes I don't want to appear in the search.
I've added a "Exclude from search" toggle property to each node, is there anyway in the code above I can exclude these nodes from being returned where this value is true?
//Filter the results to only show items where hideFromSearch is not true
results = results.Where(x => !x.Content.HasProperty("hideFromSearch") || !x.Content.Value<bool>("hideFromSearch"));
Simple search page in Umbraco 9/Cloud
I tried multiple options i found here and there, but can't get a working example.
This is our Umbraco V8 search:
This won't work in Umbraco V9/Cloud I tried code from:
Can someone point me in the right direction?
Hi I have implemented search in my starter kit which works on v9.
Here is the code in the Search page View.
Here is a link to the view code in the starter kit repo
I hope this helps
Paul
Thnx mate! With some adjustments it works perfect.
Is there anyway to get this working in v10, this line is causing an error: var results = publishedContentQuery.Search(searchQuery);
Hi Jack,
What error is it giving you exactly?
Hi Huw, thanks for getting back to me. Sorry I should've included at the time but I'm having an issue on Umbraco Cloud logs where the current days logs never load. Error message in logs: error CS0103: The name publishedContentQuery does not exist in the current context
Did you add this at the top of your view page?
@inject Umbraco.Cms.Core.IPublishedContentQuery publishedContentQuery
I did, here is my full code:
I'm also not using anything else from the start kit repo and started from a fresh Umbraco Cloud install, could this be the problem?
Odd, I'm not using cloud, but the code works fine in umbraco 10
Does anyone know how I can exclude certain pages from this search? I've copied the above which is great :) however it has content nodes like my site settings node and certain content nodes I don't want to appear in the search.
I've added a "Exclude from search" toggle property to each node, is there anyway in the code above I can exclude these nodes from being returned where this value is true?
Got it:
The issue was with my injections, once I got my error logs working I worked out the correct injections to use where:
is working on a reply...