Filter Tags in Orchard CMS to only Blogs
-
21-12-2019 - |
Question
In Orchard CMS, I'm trying to find a way to filter the Tags in the Tag Cloud to return tags only from blog posts. Right now, the Tag Cloud returns tags from all content types.
I'm using the default Tag Cloud in Orchard 1.7.1.
If there is a setting in admin, great, if not, I found a query in TagCloudService.cs. Is this the one I need to edit. If so, can someone help me with the filter I need to add here to include only blog posts
tagCounts = _contentManager
.Query<TagsPart, TagsPartRecord>(VersionOptions.Published)
.Join<CommonPartRecord>()
.Where(t => t.Container.Id == containerId)
.List()
.SelectMany(t => t.CurrentTags)
.GroupBy(t => t)
.Select(g => new TagCount {
TagName = g.Key,
Count = g.Count()
})
.ToList();
Thank you
Solution
Replace the call to Query
with .Query().ForPart<TagsPart>().ForType("BlogPost").ForVersion(VersionOptions.Published).Join<TagsPartRecord>()
.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow