Add More Link

Feb 28, 2010 at 9:35 AM

I like BreakPost Extension and of course you can use this if you enable "Number of characters" and I usually set it to 500 characters.

But .. one thing I hate is, it doesn't show "[More]" link if your entry is less than the number of characters you set.

I wrote a small extension to make this happen

 

#region using

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

#endregion

/// <summary>
/// Summary description for AddMoreLink
/// </summary>
[Extension("Add [more] link", "1.0", "BlogEngine.NET", 1010)]
public class AddMoreLink
{
	public AddMoreLink()
	{
        Post.Serving += new EventHandler<ServingEventArgs>(Post_Serving);
	}

    void Post_Serving(object sender, ServingEventArgs e)
    {
        if (!e.Body.Contains("[More]"))
        {
            Post post = (Post)sender;
            string link = "&nbsp;<a class=\"more\" href=\"" + post.RelativeLink + "#continue\">[More]</a>";

            e.Body += link;
        }
            
    }
}