+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / showing forums - postCount

showing forums - postCount

9 posts, 0 answered
  1. Mark
    Mark avatar
    24 posts
    Registered:
    16 Jun 2009
    11 Aug 2010
    Link to this post
    H,

    I am trying to create a page that shows the  most popular forum topics in a given forum or even better a category.

    Is this possible?
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Aug 2010
    Link to this post
    Hi Mark,

    There is no built in option that allows to get most popular posts/threads. You can use the ForumsManager API to get the threads/ posts count and display desired one. You can use GetPosts or GetForumThreads methods.



    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Mark
    Mark avatar
    24 posts
    Registered:
    16 Jun 2009
    11 Aug 2010
    Link to this post
    Thanks,

    I have worked out how to show the posts.

    Is it possible to show the lastpost of a thread, I noticed the forums module does this by default on the admin side, so it must be possible to do this on the public side I just cant find out how. Any clues? 

    Thread Created Posts LastPost
  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    11 Aug 2010
    Link to this post
    Hello Mark,

    GetForumPosts will return you IList so you can get an index from the list - for instance the zero based.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Mark
    Mark avatar
    24 posts
    Registered:
    16 Jun 2009
    11 Aug 2010
    Link to this post
    I am using GetForumThreads()
    This is the view I am trying to re-create in the client side.
    Thread Created Posts LastPost
    No 1 11 Aug 2010, 07:04 2 11 AUG 2010, 07:48By  Ben
    No2 15 Jun 2010, 02:33 2 30 JUN 2010, 04:05By Ben

    The only item I cannot get to work is the LastPost and I cannot find the property for the threadID so that I can pass it as a link, I have tried ParentID,  ParentForumID & ThreadID, ParentForumID.

    here is some rough code hopefully it makes sense what I am trying to do;
     if (listOfAllCategories.Count > 0)
            {
                // get first category
                Telerik.Forums.ICategory firstCategory = (Telerik.Forums.ICategory)listOfAllCategories[0];
                // The GetForums(ICategory category, bool excludeHidden) method returns an object of type IList,
                // so we create a list of all forums
                IList listOfForums = forumManager.GetForums(SelectedCategory, false);
                List<Telerik.Forums.Data.Post> postList = new List<Telerik.Forums.Data.Post>();

                if (listOfAllCategories.Count > 0)
                {
                    foreach (Telerik.Forums.IForum forum in listOfForums)
                    {

                        Response.Write(forum.Name + "<br />");
                        //get threads
                        IList listOfPosts = forumManager.GetForumThreads(forum, false);
                        
                        foreach (Telerik.Forums.Data.Post postItem in listOfPosts)
                        {
                            postList.Add(postItem); //postItem
                        }

                        if (listOfPosts.Count > 0)
                        {
                            uxlatestPosts.DataSource = postList;
                            uxlatestPosts.DataBind();
                        }
                    }
                }
             }
  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    17 Aug 2010
    Link to this post
    Hi Mark,

    You have to work with IPost interface not with data object - Telerik.Forums.Data.Post. Then you can call  ((IPost)posts[0]).ID.ToString() or  ((IPost)posts[0]).Thread.ID.ToString() for the first item.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Rok
    Rok avatar
    7 posts
    Registered:
    08 Apr 2008
    01 Dec 2010
    Link to this post
    Hmmm Telerik.Forums.Data.Post implements IPost  interface, so there really shouldnt be any difference between  ((IPost)posts[0]).ID.ToString()  and  (posts[0]).ID.ToString().

    Mark, did you managed to get it to work? I will post my solution soon, but it doesent look very elegant.

  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    25 Nov 2016
    01 Dec 2010
    Link to this post
    Hello Rok,

    Telerik.Forums.Data.Post is the data class since IPost is the interface. The data class is used in the provider that gets/sets the data to your database.

    Sincerely yours,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Rok
    Rok avatar
    7 posts
    Registered:
    08 Apr 2008
    01 Dec 2010
    Link to this post
    forumManager.GetForumPosts(post.ForumID) returs System.Collections.IList {Telerik.Forums.Data.Posts}. Casting Telerik.Forums.Data.Post  to interface that it implements and calling property or calling the same property on the object does not make  a difference :)



Register for webinar
9 posts, 0 answered