Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hello,
I have pages containing tags. Let's say Home has the tag home, Page 1 has the tag Sports and Page 2 has the tag Sports,Entertainment.
How can I get a list of all pages that would contain the tag Sports and link to them?
Hi Steve
I think you have to try GetContentByTag method:
var taggedContent = Umbraco.TagQuery.GetContentByTag("tagname");
Then you will be able to get all properties of tagged pages. Hope this is what you want to achieve.
Thanks,
Alex
Did you find out how to do it?
/Alex
Hi Alex,
Yes I figured out how to do it. I did it this way in the end:
@{ //Get All Available Tags for the Sports Page var allTags = Umbraco.TagQuery.GetAllTags(); if(CurrentPage.Name == "Sports") { <ul class="list-inline"> <li><a href="@CurrentPage.Url">All Tags</a> @foreach (var tag in allTags) { var url = @CurrentPage.Url + "?tag=" + HttpUtility.UrlEncode(@tag.Text); <li><a href="@url">@tag.Text</a></li> } </ul> }
}
Glad that you figured out how to do it. Thanks for sharing the code example!
Have a nice day.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Find All Pages Containing Tags in Razor
Hello,
I have pages containing tags. Let's say Home has the tag home, Page 1 has the tag Sports and Page 2 has the tag Sports,Entertainment.
How can I get a list of all pages that would contain the tag Sports and link to them?
Hi Steve
I think you have to try GetContentByTag method:
Then you will be able to get all properties of tagged pages. Hope this is what you want to achieve.
Thanks,
Alex
Hi Steve
Did you find out how to do it?
/Alex
Hi Alex,
Yes I figured out how to do it. I did it this way in the end:
}
Hi Steve
Glad that you figured out how to do it. Thanks for sharing the code example!
Have a nice day.
/Alex
is working on a reply...