Copied to clipboard

Flag this post as spam?

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


  • Thomas 212 posts 480 karma points c-trib
    Sep 21, 2017 @ 14:36
    Thomas
    0

    Get all pages with a tag ex. "apple" or "Samsung"

    Hey.

    I'm trying to get all pages that are tagged with a specific tag, ex. "apple", "samsung"

    I'm using this to list all the tags:

    @{
        var tagList = Umbraco.TagQuery.GetAllTags("news").OrderBy(t => t.Text);
        <ul>
            @foreach(var tag in tagList)
            {
                <li>@tag.Text</li>
            }
        </ul>
    }
    

    but I would like to get all pages with there url and name listet.

    Hope anyone can help, thanks

    // Thomas

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Sep 21, 2017 @ 14:48
    Alex Skrypnyk
    101

    Hi Thomas

    You can get all pages with this code:

    var nodesTags = Umbraco.TagQuery.GetContentByTag("testTag", "tagGroup");
    

    Example:

    @{
        var nodesTags = Umbraco.TagQuery.GetContentByTag("testTag", "news");
        <ul>
            @foreach (var node in nodesTags)
            {
                <li><a href="@node.Url">@node.Name</a></li>
            }
        </ul>
    }
    
  • Thomas 212 posts 480 karma points c-trib
    Sep 21, 2017 @ 14:55
    Thomas
    1

    Brilliant! Thanks Alex. Saved my day ! :D

  • Alex Skrypnyk 5908 posts 22603 karma points MVP 4x admin c-trib
    Sep 21, 2017 @ 14:58
    Alex Skrypnyk
    1

    You are welcome, Thomas, have a great rest of the day!

  • Thomas 212 posts 480 karma points c-trib
    Sep 21, 2017 @ 15:09
    Thomas
    0

    Thanks you, you too :)

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies