Copied to clipboard

Flag this post as spam?

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


  • Marc-André 63 posts 279 karma points
    Apr 10, 2019 @ 18:27
    Marc-André
    0

    Get pagenodes with tags

    Hello!

    I'm trying to get pages with a certain tag. Here's my code :

    var selection = Umbraco.ContentAtRoot().FirstOrDefault()
        .Children()
        .Where(x => x.IsVisible())
        .Where(x => x.Value<string>("tags").Contains("legume"));
    

    I don't have any error but I get no result.

    Thanks :D

  • Corné Strijkert 80 posts 456 karma points c-trib
    Apr 10, 2019 @ 19:27
    Corné Strijkert
    100

    Hi Marc-Andre,

    The x.Value<string>("tags") is the wrong part in you query. This code outputs 'System.String[]' and contains never the text 'legume' :)

    The tags datatype value is not a single string, but an array of strings. Try x.Value<string[]>("tags") instead.

  • Marc-André 63 posts 279 karma points
    Apr 10, 2019 @ 19:32
    Marc-André
    1

    Oh god. So logic. Thanks again Corné :D

Please Sign in or register to post replies

Write your reply to:

Draft