Most Popular Posts Extension and Widget

-   Mar 02, 2008 -   BlogEngine.NET, Development -   , , ,

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. 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 TopPostsExtension TopPostsWidget (for BlogEngine.NET 1.3)

 Quotes of the Day Widget Installation and Update

-   Feb 27, 2008 -   BlogEngine.NET, Development, Screencasts -   , , , , ,

Over the past few weeks, I've received a bunch of questions on using the Quote of the Day widget so I had been planning to put together a quick walk through screencast to show you how to use since I really didn't cover usage very thoroughly in my earlier post. Since I was working on a new theme earlier this week, it seemed like the right time to do this, but I also find a minor bug with the control when previewing themes so I made a small change to correct this.  It was a minor fix, but if you are starting fresh or feel like upgrading, I'll include the updated control at the end of this post. The screencast walks you through adding the widget from download to theme update.  I don't cover making changes to your CSS to make it look the way you want in your theme, but I've tried in in 4 themes already and haven't needed to do anything special to make the widget look right.  I'll include the register and usage line below so you can see them more clearly and don't have to copy notes while watching the screencast.

<%@ Register src="QuoteOfTheDay.ascx" TagName="quote" TagPrefix="uc2" %>


<uc2:quote ID="QotD" runat="server" />
Again, this widget works fine in 1.2 and 1.3.  I'll make an updated version when 1.4 gets closer.  You can download the QuotesWidget 1.0.1 here.

 New BlogEngine.NET Widget: Quote of the Day

-   Jan 16, 2008 -   BlogEngine.NET, Development, Screencasts -   , , ,

I love quotes.  I enjoy seeing new quotes and I like to save them if it is handy.  I used to have a text file of quotes I collected, but it was lost in the great hard drive crash of 2007. As I do enjoy quotes, I made a BlogEngine.NET widget for use in themes for collecting quotes and displaying a new one everyday.  I've been using it for a few months now and I'm finally getting around to sharing it with the BlogEngine.NET community. "Uhhhh, ok, Al.  So you what exactly are you giving me?" Great question.  I'm sharing a widget (or control) you can add to an existing theme.  Yes, this will only help someone who is interesting in working on modifying themes.  I'll likely release this theme, Refresh, with the control embedded in the coming days, but until then, you get the widget by itself.  The widget is simply a standard user control (an ascx file) and its code-behind file. Let me show you how it works.  I made a short (under a minute) screencast showing you how the widget/control works.  For those, to impatient to watch or just completely sick of my screencasts, here is the text version. As you'd expect, the widget shows you a new quote everyday from your collection of quotes.  It will pick a new quote based on when it was last displayed.  When you are logged in however, it gives you buttons to allow you to add, edit, delete, and navigate your quotes collection.  It is fairly simple.  No admin page, no hassle.  Just drop the control in your theme as you would any user control and it will work for you. "Wow... This is great.  I can just add this to my theme and my quotes will just magically be saved in my blog.  So where are these quotes stored?"  Another excellent question.  To keep things simple, they are stored in an xml file in your App_Data folder.  Widget data will be provider based in the next version of BlogEngine.NET, but for now it is not.  When the widget is first run, it will find that there is no quotes.xml file and it will create it for you. One thing I really like about this widget is that it is a simple piece of a theme.  It doesn't require you to install files in different places to use it.  I prefer to keep my blog add-ons as separate as possible from the rest of the blog.  (In other words, I think a theme should stay in its folder and not need files put in other places.  The same should go for extensions as much as possible.  This just makes updating my blog much simpler.) This widget works fine in version 1.2 and 1.3 and can be downloaded here.