Virtual Happy Hour is canceled this month (March) due to Good Friday.
Virtual Happy Hour is canceled this month (March) due to Good Friday.
Any reason why you are using GetQueryResults?
I would create a function like this:
private static MessageCollection GetRecentlyCreated(RoomBase room, int page, int pageSize, out int totalItems)
{
// Recently created
TopicSortOrder sortOrder = new TopicSortOrder(TopicSortField.Created, SortingDirection.Descending);
MessageCollection topics = ForumHandler.Instance.GetTopics(new RoomCollection { room }, EntityStatus.Approved, page, pageSize, out totalItems, sortOrder);
return topics;
}
Then also add, if you don't have an addition to your pagebase that gets the CurrentRoom you want to fetch from:
public RoomBase CurrentRoom
{
get
{
int roomId;
if (Request.QueryString["roomId"] != null && Int32.TryParse(Request.QueryString["roomId"], out roomId))
return ForumHandler.Instance.GetRoom(roomId);
return ForumHandler.Instance.GetRoom(-1);
}
}
Then fetch the items and add them to a listview or something similar
int totalItems;
lstView.DataSource = GetRecentlyCreated(CurrentRoom, 1, 5, totalItems);
lstView.DataBind();
Hi,
If you still want to use the QueryResult function, add this to the query:
query.Room = new RoomCriterion();
query.Room.ID = new IntegerCriterion();
query.Room.ID.Includes = new IntegerInCriterion();
query.Room.ID.Includes.Values.AddRange(roomIDs);
where roomIDs is the ids of the rooms in the forum you want get topics from.
// Regards, Torbjörn
I am currently working with Relate plus 1. What version do you work in? Anyways, this is how I solved it.
TopicQuery topicQuery = new TopicQuery();
topicQuery.CreateDate = new DateTimeCriterion();
topicQuery.Room = new RoomCriterion();
topicQuery.Room.Parent = new RoomCriterion();
topicQuery.Room.Parent.Forum = new ForumCriterion();
topicQuery.Room.Parent.Forum.ID = new IntegerCriterion();
topicQuery.Room.Parent.Forum.ID.Value = ForumIDForTheForumYouWantToSearch;
CriterionSortOrder critSort = new CriterionSortOrder(topicQuery.CreateDate, EPiServer.Common.Sorting.SortingDirection.Descending);
topicQuery.OrderBy.Add(critSort);
MessageCollection topics = QueryHandler.GetQueryResult<EPiServer.Community.Forum.Topic, MessageCollection>(topicQuery, 1, ThreadsCount);
Hope this helps :-)
Hi,
I would like to display the 5 latest topics from a forum.
Currently my code loks like this:
The problem is that this gets topics from all the different forums. How can I get topics from a specific forum?