Copied to clipboard

Flag this post as spam?

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

  • Marco Vezzani 12 posts 145 karma points
    Mar 11, 2019 @ 14:08
    Marco Vezzani

    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.


    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")

    enter image description here

    Has something changed from v7 to 8 that I have missed, as surely this can't be a bug?

  • Marco Vezzani 12 posts 145 karma points
    Mar 12, 2019 @ 15:13
    Marco Vezzani

    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.

  • Scott Leslie 24 posts 139 karma points
    Mar 19, 2019 @ 16:34
  • Scott Leslie 24 posts 139 karma points
    Mar 20, 2019 @ 13:10
    Scott Leslie

    bug confirmed


    var selection = Umbraco.Content(Guid.Parse("1d770f10-d1ca-4a26-9d68-071e2c9f7ac1")) .ChildrenOfType("blogpost") .Where(x => x.IsVisible());

  • Tony Lorentzen 55 posts 132 karma points
    Mar 25, 2019 @ 14:19
    Tony Lorentzen

    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.

  • Bryna 58 posts 219 karma points
    Mar 25, 2019 @ 21:50

    Does the same thing happen when you utilize something like below?

    Umbraco.Content(Guid.Parse("257194d6-4dba-4a4e-937b-47e63dd06595")).Children<Place>().Where(x => x.IsVisible())
  • Marco Vezzani 12 posts 145 karma points
    Apr 04, 2019 @ 12:34
    Marco Vezzani

    That worked as well, thanks Bryna

Please Sign in or register to post replies

Write your reply to: