Partial View Query Builder and filtering results in umb 8
I have finally got around to playing about with Umb8 and built a very simple site with it. All was going well until I realised I seem to have an issue with the partial view query builder and filtering results.
I set up a news section (news homepage) with news item document types below this. I used the query builder to pull out the news items and it all looked ok as there were only news items below the homepage.
But when I create a different document type under the News homepage beside the News Item ones these show up in the results even when I change the query to filter only the news item ones.
I then tried to do a similar query to filter only a specific document type this time starting from my root document type and I discover that it pulls in all document types again even though I have specified what children to filter for.
e.g.
Umbraco.Content(Guid.Parse("d4f3a31e-9785-44e3-9ef5-1d77dfca4994")).Children("place")
Has something changed from v7 to 8 that I have missed, as surely this can't be a bug?
So after playing about with all of this a bit more, I found two different ways to get the desired results. The first one I tired that worked was to put a OfTypes on my for each results but obviously this is filtering the results after pulling them.
foreach (var item in selection.OfTypes("place"))
After I tried a few other things then hit upon this:
var selection = Umbraco.Content(Guid.Parse("3c53eaa2-1d30-4a4b-b390-16782e42282c")).Children().Where(x => x.ContentType.Alias == "place").Where(x => x.IsVisible());
This worked as well, but I still don't get why adding in the document type into the Children() doesn't work (when it used to in v7 and below) esp when it was the query builder that was putting it all together.
Urgh - been banging my head against the wall to get this working. It's incredibly frustrating something as basic as this isn't working in a new major build. There's something odd going on with the Model in v8 causing me to use 20-30% added time on client projects. Very frustrating.
Partial View Query Builder and filtering results in umb 8
I have finally got around to playing about with Umb8 and built a very simple site with it. All was going well until I realised I seem to have an issue with the partial view query builder and filtering results.
I set up a news section (news homepage) with news item document types below this. I used the query builder to pull out the news items and it all looked ok as there were only news items below the homepage.
But when I create a different document type under the News homepage beside the News Item ones these show up in the results even when I change the query to filter only the news item ones.
e.g.
Umbraco.Content(Guid.Parse("257194d6-4dba-4a4e-937b-47e63dd06595")).Children("newsItem").Where(x => x.IsVisible())
I then tried to do a similar query to filter only a specific document type this time starting from my root document type and I discover that it pulls in all document types again even though I have specified what children to filter for.
e.g. Umbraco.Content(Guid.Parse("d4f3a31e-9785-44e3-9ef5-1d77dfca4994")).Children("place")
Has something changed from v7 to 8 that I have missed, as surely this can't be a bug?
So after playing about with all of this a bit more, I found two different ways to get the desired results. The first one I tired that worked was to put a OfTypes on my for each results but obviously this is filtering the results after pulling them.
After I tried a few other things then hit upon this:
This worked as well, but I still don't get why adding in the document type into the Children() doesn't work (when it used to in v7 and below) esp when it was the query builder that was putting it all together.
Same . Raised a issue .... https://github.com/umbraco/Umbraco-CMS/issues/5024
bug confirmed
Workaround:
var selection = Umbraco.Content(Guid.Parse("1d770f10-d1ca-4a26-9d68-071e2c9f7ac1")) .ChildrenOfType("blogpost") .Where(x => x.IsVisible());
Urgh - been banging my head against the wall to get this working. It's incredibly frustrating something as basic as this isn't working in a new major build. There's something odd going on with the Model in v8 causing me to use 20-30% added time on client projects. Very frustrating.
Does the same thing happen when you utilize something like below?
That worked as well, thanks Bryna
is working on a reply...