This project is read-only.

Tag cloud: How to limit number of tags rendered?

Topics: Customizing Orchard, General
Oct 7, 2014 at 9:26 PM
Hello, I run into problem with my tag cloud. I have no idea how many tags there will be over time. I would like to have say 50 most used tags displayed and the others simply ignored. The settings only allow me to specify "buckets" or where to scoop tags.

I can modify TagCloud.cshtml but I don't know how it works. If I take 50 first tags, then it is sorted alphabetically... Maybe Linq could help?

The problem with Linq is that I cannot get it to work. I added using System.Data.Linq but Take method did not work for example.

Thanks for help.
Oct 7, 2014 at 9:58 PM
Please file an issue, we could add a property to set the maximum number of tags to display. You can try to implement it if you think you are up to the task.
Oct 8, 2014 at 8:23 AM
Edited Oct 8, 2014 at 9:25 AM
I could certainly try to provide implementation. The problem is it did not occurre to me that this could be a problem and I would like to have some fast solution albeit temporary.

Could it by done by Linq extensions? Sort tags by number of occurrences and then do .Take? I could get Linq to work inside my TagCloud view.

EDIT: The problem with Linq was that I tried to cast it on dynamic object, after using conversion my temporary solutions works:
var tags = ((List<TagCount>)Model.TagCounts).OrderBy(t => t.Count).Take(40)
It just orders tags by occurrence and displays 40 most popular.

I'll start working on correct implementation so it can be set in administration.