Most Popular Posts Extension and Widget

A few weeks back, I read a post from Damien Guard on his favorite WordPress plugins.  While reading over his list, I felt BlogEngine.NET really had them all cover and then I got the last one, WP-PostViews.  The plug in as you might guess, counts, post views and has a side bar widget for displaying the most popular content.  Damien writes:

Another visitor-retention seeking effort. By presenting the most popular content in the sidebar I'm hoping to entice people to look at a couple of other posts and hit the magic RSS subscribe button.

Well, I decided to whip up the BlogEngine.NET version which consists of an extension to count the post views and a widget to use in your theme.  The extension could certainly be more elegant, but it gets the job done.

TopPosts The widget is a little more complex, but not much.  It reads in the counters, determines the top posts, and displays them in a list.  You can control how many of the top post will display in the widget with the Top property (which is expecting an integer of how may posts to display).  There is also a ShowViewCount property which is expecting a true or false.  If you set it to true, it will show the world the actual post counts it is generating.  If you set it to false, it is only visible when you are logged in.  (Note: The top posts are cached and will only update on your site every 30 minutes.  No point in calculating these number too frequently.)

To set this up, download the files below and unzip them.  The extension file (TopPosts.cs) needs to be placed in your extensions folder which is at App_Code/Extensions.  The Widget files should go in the theme you plan to add the widget to.  Once you have the widget files in the theme folder, you can go ahead and add the widget to the site.master file or wherever you'd like.  The correct syntax for the user control will look something like the following.


<%@ Register src="TopPosts.ascx" TagName="topPosts" TagPrefix="uc3" %>


<uc3:topPosts ID="TopPosts1" runat="server" Top="5" ShowViewCount="false" />

If you have issues installing the widget, please see the Installing the Quote of the Day widget screencast.  The process is very similar.

I put together a screencast on the creation of the extension and was planning to do the same for the widget, but they seem so simple and redundant, I'm not sure I'll follow through with completing them. Let me know if you are interested in these.  If there is enough interest, I'll make them happen.

Downloads

Comments

3/5/2008 1:47:48 AM #

Damien Guard

BlogEngine.NET is looking better and better.  I should give it another go!

[)amien

Damien Guard United Kingdom |

3/5/2008 7:53:31 AM #

Catto

Hey Now Al,
This looks pretty nice, I also really like the Archive tab a lot too.
Thx 4 the info,
Catto

Catto United States |

3/5/2008 1:06:29 PM #

Scott

It throws an exception when you have no posts in the blog.  Because I am starting up a blog soon, I wanted to look around for widgets and found this one to be cool, but You shouldn't let it throw exceptions at line 49.  I solved it by just putting a try catch block around it.

Thought I would give you the update.

Scott United States |

3/5/2008 3:56:57 PM #

Al Nyveldt

Thanks Scott.  

The error occurs when the Counters folder doesn't exist.  I made the correction and posted the updated version of the widget.

Al Nyveldt United States |

3/5/2008 6:35:29 PM #

Krishnan

I also got this error, fixed by creating a folder manually ;)

A great extension, Thanks

Krishnan India |

3/9/2008 12:47:35 AM #

Scott Marlowe

Very nice. Thanks!

I had a bit of an issue just at first where the "shortList" was coming back with 0 elements as opposed to null, so it failed to enter the section of code that does all the gathering, sorting, etc.

But now it's working fine, so not sure what was going on there.

Scott Marlowe United States |

3/14/2008 10:33:43 PM #

Cristiano

Hi Al,
thank you so much for thi extension/widget.
For a long time I wanted to write an extension of this kind ...
I have avoided work Wink

Cristiano Italy |

3/27/2008 5:48:11 AM #

Roberto Briones

Hi, Thanks for the extension, is nice!

Roberto Briones Mexico |

3/27/2008 7:36:13 AM #

Piratas

Thanks, BlogEngine.NET show that not every program on windows is bad.

Piratas Chile |

3/27/2008 5:31:18 PM #

Sam

Thakns, is perfect...

Sam Spain |

3/28/2008 3:54:24 PM #

test

<a href="http://www.test.com">test</a>

<a href="test.com">test</a>

test United States |

3/30/2008 10:06:58 AM #

LesNoticias.com

Me encanta vuestra web. Aprendo mucho.

gracias y seguir asi.

www.lesnoticias.com

LesNoticias.com Spain |

3/31/2008 1:09:48 PM #

Dan

I really appreciate how you built the control as a "template" so that we can arrange and format it rather easily.

Thanks!

Dan United States |

4/3/2008 12:54:25 PM #

pingback

Pingback from tim-stanley.com

Site Info - Tim-Stanley.com

tim-stanley.com |

4/15/2008 4:56:09 PM #

pingback

Pingback from news.newbuzz.info

Survey Profiling | Latest News Blog

news.newbuzz.info |

6/21/2008 9:34:31 AM #

pingback

Pingback from lypang.com

BlogEngine.NET Most Popular Posts Extension Fix

lypang.com |

12/23/2009 8:28:54 PM #

trackback

Popular Posts

Popular Posts

scottmarlowe.com |

2/25/2010 11:39:13 AM #

pingback

Pingback from italianbloggers.it

Rilasciato Feedburner Stats extension component  - ItalianBloggers

italianbloggers.it |

Comments are closed
Recent Comments