Archive for the ‘Widgets and Extensions’ Category

Download Tracker v1.0

Thursday, February 26th, 2009

I’ve been meaning to learn how to write extensions and widgets for BlogEngine.Net for a while now.? I’ve been using this website as an excuse to play around with web-development, which is part of the reason why

  1. The site is often broken.
  2. The site is often changed for no apparent reason.

In this case, the widget and extension I wrote covers functionality already built elsewhere, but let’s face it, what’s the fun in using their code?? Besides, implementing this gave me a chance to look at how other folks wrote their extension, and served as a good learning experience.

Essentially there are 3 parts to this widget/extension.? The first part is the extension.? This is required in order for the widget to work, and tracks the number of times a file is served via the FileHandler service.? It uses the settings provider and saves a count of the number of times the file was served.? No information about who, what, why, where the person came from is recorded, because frankly I don’t really care.? All I am really interested in is which files are popular and which aren’t.? The second part is the DownloadList control.? This simply renders an unordered list of the files and their download counts.? This control can be used anywhere if you have a pressing desire to do so.? The final part is the widget “Download Tracker”.? This hosts the DownloadList control as a widget.? The widget is only displayed to authenticated users.?

Eventually, I might throw together a “most-popular” widget that would display the top five most popular downloads or something like that, but for now I just wanted a way to count the number of times a file is downloaded.

I have 2 other widgets/extensions I plan to implement (in addition to my Trailhead Estimate development).? The first is an AddToAny widget to add the control and customize it.? The second is a “most-popular post” type widget, to help direct visitors to the posts most enjoyed by everyone else.

As always, visit the Download Page to grab the extension/widget.? It is organized according to the directory structure the files should be placed in:

  • The “Download Tracker” folder and its contents should be saved to the “widget” directory.
  • The “DownloadTracker.cs” file should be saved in “App_Code\Extensions”.
  • The “DownloadList.cs” file should be saved in “App_Code\Controls”.

That is all you need to do to install it.? From there, you should see “DownloadTracker” in the extensions, just enable that and add the “Download Tracker” widget to the widget collection and you are done.