This project is read-only.

Post Tags

Topics: ASP.NET 2.0
Jun 28, 2008 at 1:38 AM
I'm stumpted on this solution and maybe someone can help "shine the light" and get me rolling.  I'm using the BlogEngine on a website of which I've donated my time for and what I've done is create two categories; one for news and events and the other for features.  I have a details page for each category, using the GetPostByCategory method.  What I need to do now is then show all the various Tags for all these post in this category; kind of like a subcategory, so that when the visitor clicks on the Tag it will filter all post with those tags.

So my question is what method can I use to iterate through all the post and get all tags that will then get added to a DataTable in order to fill a DataList.

Jun 28, 2008 at 5:49 AM
Never mind as I figured it out.  For those that read this post looking for a simular solution, this is what I came up with;


//Since this page is for Events/News I create



//a GUID variable



Guid _cat = new Guid("91da5f03-77ad-4a72-b349-803b8540f75d");



//Create a



List<Post> list = Post.GetPostsByCategory(_cat);



//Create HashTable to hold the tags as keys



Hashtable ht = new Hashtable();




//Used to count the number of tags



int x = 0;



//Iterate through the Post



foreach (Post _p in list)




//Iterate through each tag in Post



foreach(string _item in _p.Tags)




//Check if tag item already assigned



if (ht.ContainsKey(_item.ToString()))



ht[_item.ToString()] = x +









//Tag does not exist so assign






//Iterate through HashTable and fill DataTable



foreach (DictionaryEntry de in ht)




DataRow dr = dtCat.NewRow();



"Tag"] = de.Key.ToString();



"Count"] = Convert.ToString(ht[de.Key.ToString()]);





//Assign DataTable to DataList



this.categories.DataSource = dtCat;