web 2.0

WebDevVote Button At The End Of Each Post Extension for BlogEngine

Hi,

Here is a simple Extension for BlogEngine in order to add the WebDevVote Button at the end of each Post without needing to add some “Tokens” in posts.

Just put this Code Snippet into App_Code/Extensions of your BlogEngine Web Site.

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

/// <summary>
/// Summary description for WebDevVote
/// </summary>
[Extension("Add WebDevVote Button to Post", "1.0", "http://blog.sb2.fr")]
public class WebDevVote
{
    public WebDevVote()
    {
        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;
        if (e.Location != ServingLocation.SinglePost)
            return;

        StringBuilder sb = new StringBuilder(e.Body);
        sb.Append("<br/><br/>");
        sb.AppendFormat("<a href=\"http://www.webdevvote.com/vote/?url={0}&amp;title={1}\" ", post.AbsoluteLink, post.Title);
        sb.Append("target=\"_blank\" style=\"background-color:Transparent;border:none;padding:0;margin:0\">");
        sb.AppendFormat("<img src=\"http://www.webdevvote.com/Services/Images/KickItImageGenerator.ashx?url={0}\" border=\"0\" alt=\"vote it on WebDevVote.com\" ", post.AbsoluteLink);
        sb.Append("border=\"0\" style=\"background-color:Transparent;border:none;padding:0;margin:0\" />");
        sb.Append("</a>");
        e.Body = sb.ToString();
    }
}

Hope this help’s.



Views(1095)

kick it on DotNetKicks.com

Share/Save/Bookmark Subscribe

Currently rated 4.0 by 2 people

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

Tags:

C#

Comments

Technorati Profile