Generate a distinct list of 'categories' assigned to a set of nodes. This code loops through a set of nodes, creates an array from the categories on each node, then we get only the distinct ones. This array can then be looped through again to build a list of your categories.
@using Contensis.Framework.Web.Search;
@{
var query = Query.Where("Property_Path").StartsWith("/connect/blog/").And("Property_AuthorID").IsEqualTo(authorId.ToString()).OrderBy("Property_Title");
var nodes = new NodeFinder().Find(query, selectCount: 20);
string fulltagslist = "";
}
@foreach(var node in nodes)
{
fulltagslist += node.Data.BlogCategories + ",";
}
@{
string[] myfulltagslist = fulltagslist.Split(',');
myfulltagslist = myfulltagslist.Distinct().ToArray();
}
<ul class="sys_tagcloud-control">
@if(myfulltagslist.Length != 1){
foreach (string tag in myfulltagslist)
{
if (tag != "")
{
<li class="sys_tagcloud-tag"><a href="/Connect/blog/blog-archive.aspx?category=@tag">@tag</a> </li>
}
}
} else {
<li class="sys_tagcloud-tag">There are no categories available. </li>
}
</ul>