Is this related to the Blog templates in EPiServer demo package or EPiServer Community?
We are using Relate+ and CMS 5. What I am looking for is a code sample for how I can filter out all entries for a certain blog object with a certain tag name.
Does anyone know how to solve this? The documentation states to use TagHandler.Instance.GetTaggedItems but there is no Instance member variable in TagHandler and the GetTaggedItems is declared as internal.
Finally have a solution for this. Below is a code example of a function that finds entries in a blog with a specified tag:
public static EntryCollection GetEntriesByTag(Blog blog, string tagString, int page, int pageSize, out int totalItems)
EntryQuery entryQuery = new EntryQuery();
entryQuery.Blog = new BlogCriterion();
entryQuery.Blog.ID = new IntegerCriterion();
entryQuery.Blog.ID.Value = blog.ID;
// Create a TagCriterion
TagCriterion tagCrit = new TagCriterion();
tagCrit.Name = new StringCriterion();
tagCrit.Name.Includes = new StringInCriterion();
// Create a entityTagCriterion, and use the TagCriterion created
EntityTagCriterion entityTagCriterion = new EntityTagCriterion();
entityTagCriterion.Tag = tagCrit;
// Finally, set the Tags property
entryQuery.Tags = new TagCollectionCriterion();
entryQuery.Tags.Containing = new MultipleEntityTagCriterion();
entryQuery.Created = new DateTimeCriterion();
entryQuery.OrderBy.Add(new CriterionSortOrder(entryQuery.Created, SortingDirection.Descending));
EntryCollection entries = BlogHandler.GetQueryResult(entryQuery, page, pageSize, out totalItems);
What was a bit tricky to figure out was that you should use both TagCriterion and EntityTagCriterion, and how these correlate.
// Regards, Torbjörn Stavås
Thanks. Just what I was looking for.Works like a charm.
I want to be able to filter blog entries by tag but cant figure out how. I can see that there is something called TagCriterion that could be used. If so, how?