I wanted to add a sidebar block showing the most popular tags on the site but didn't want to use any extra contributed modules. It turns out it's actually quite easy to do using Views.
- Download and install Views if you don't have it already.
- Create a view to Show Taxonomy Terms and click Create a block if you want the sidebar block.
- Click Advanced and add a Relationship to Taxonomy term: Content using Tags
- In Advanced under Other set Use aggregation to yes.
- Add the Taxonomy term: Name field twice. Set the aggregation settings of the first to Group results together and the second to Count.
- You can add a Prefix and Suffix of ( and ) so that the number of times the Tag appears is in parenthesis.
Enjoy!
Comments
nicholas (not verified)
April 7, 2013 - 03:00
Permalink
php web hosting
thanks for giving the correct way to add sidebar.
Kevin
April 17, 2013 - 01:06
Permalink
You're welcome!
You're welcome!
Mike (not verified)
April 28, 2014 - 14:26
Permalink
Worked for me, but instructions slightly unclear
Thanks Kevin! The steps above worked for me, but step 5 is a little unclear. The following modification worked for me:
5. Add the "Taxonomy term: Name" field twice. Set the first to aggregate by "Group by", and the second by "Count". I also added a prefix of " (" and suffix of ")" to the second field, such that the output of a single term looks something like: hamburgers (5)
Mike (not verified)
April 28, 2014 - 14:30
Permalink
Almost forgot
Also in Show: Fields > Settings, check the two fields under "Inline fields" to get them to appear next to each other, or alternatively set up some form of Rewrite.
Kevin
May 3, 2014 - 22:22
Permalink
Thanks
I made this change to the instructions.