web 2.0

DotNetKicks Button Extension for BlogEngine.NET

Hi !

Just wrote a little Extension for BlogEngine.NET in order to add DotNetKicks Button at the bottom of each Posts.

Unlike Sean BlogEngine.NET DotNetKicks Button Extension which needs to add a Token in the post before Publish it, the following code Add a DotNetKicks Button at the end of each post automatically.

using System;
using System.Collections.Generic;
using System.Web;
using BlogEngine.Core.Web.Controls;
using BlogEngine.Core;
using System.Text;

/// <summary>
/// Summary description for KickIt
/// </summary>
[Extension("Add KickIt Button to Post", "1.0", "http://blog.sb2.fr")]
public class KickIt
{
    public KickIt()
    {
        Post.Serving += new EventHandler<ServingEventArgs>(Post_Serving);
    }

    private static void Post_Serving(object sender, ServingEventArgs e)
    {
        Post post = sender as Post;
        if (post == null)
            return;

        StringBuilder sb = new StringBuilder(e.Body);
        sb.AppendFormat("<a href=\"http://www.dotnetkicks.com/kick/?url={0}&amp;title={1}\" target=\"_blank\">", post.AbsoluteLink, post.Title);
        sb.AppendFormat("<img src=\"http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx?url={0}\"", post.AbsoluteLink);
        sb.Append("border=\"0\" alt=\"kick it on DotNetKicks.com\" />");
        sb.Append("</a>");

        e.Body = sb.ToString();
    }
}

Copy the KickIt.cs into App_Code/Extensions folder of your BlogEngine.NET Web Site.

 

Hope this help's !



Views(1013)

kick it on DotNetKicks.com

Share/Save/Bookmark Subscribe

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

C#

Comments

Add comment


 

biuquote
Loading



Technorati Profile