Most Discussed Custom Widget

Posted by Community Admin on 04-Aug-2018 16:22

Most Discussed Custom Widget

All Replies

Posted by Community Admin on 28-Feb-2012 00:00

I'm hoping someone can give me some help with a custom widget I'm developing. I think all I actually need is syntax help.

I'm creating a custom widget to display the most discussed blog posts. That has gone well, and I have the ability to specify a certain number of blog post summaries to show up, ordered by how many comments they have. This is the code I'm using:

int count = int.Parse(_maxNumberPosts); // this is a public property on the control
var recentPosts = App.WorkWith().BlogPosts().Publihed().OrderByDescending(b => b.Comments.Count).Get().Take(count);
rptblogMostDiscussed.DataSource = recentPosts;
rptblogMostDiscussed.DataBind();

What I would like, is to add a second public property, so that when placing the control on a page, you can specify for how many days comments should be considered. For example, if I set it to 14, it would only consider comments made in the last 2 weeks, instead of the way it currently works which uses a lifetime grand total of all comments.

Can someone help me as to how I would do this?

Posted by Community Admin on 02-Mar-2012 00:00

Hi Raymond,

 What I can suggest here is adding a DatePicker control (for example) and wiring it up to a property in your code-behind. Then in the query, you can use the selected value from the DatePicker and using a Where clause, before the OrderByDescending command, filter the blog posts by Comment.PublicationDate for all the dates that are after the selected one. Let me know if you have specific questions on the implementation (syntax) for this.

Greetings,
Svetoslav Petsov
the Telerik team
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items

This thread is closed