.NET and Open Source: better together


  • Join Us on Facebook!
  • Follow Us on Twitter!
  • LinkedIn
  • Subcribe to Our RSS Feed

Post Paging Extension

Reading this thread on Codeplex I was going to write that no such functionality exists but probably easy to add. But then I though just how easy it really would be? So I fired up Visual Studio and about half an hour later I got functioning plugin that does exactly what requested. And this is why I like BlogEngine - it is insanely easy to customize. At least, when you get used to it because documentation admittedly sucks.

What this extension does is it lets you split blog post into multiple pages by inserting page-break markers as shown in the picture below.

When you looking at the post list, you'll see first page with links to other pages.

After clicking link to the page two, you'll get to the single post with second page loaded, and clicking other links will reload page as expected, so visitor can navigate through the post topics.

I'm not necessarily thrilled with idea of hunting for the clicks, but this has valid and useful cases when you want represent content as several related topics and don't want to split them into separate posts.

And complete code is below, just in case you want to modify it or do something useful and need simple example. It also can be installed from BE gallery as compiled plugin using admin panel, as usual.

using System;
using System.Linq;
using System.Web;
using BlogEngine.Core;
using BlogEngine.Core.Web.Controls;
using BlogEngine.Core.Web.Extensions;

    "Breaks a post into pages where [pagebreak] is found in the body and adds links to pages", 
    "<a href=\"http://www.rtur.net\">rtur.net</a>", 
public class PostPaging
    private static Post _post;
    private static string _separator = "[pagebreak]";
    private static string[] _pages;

    static PostPaging()
        Post.Serving += PostServing;

    private static void PostServing(object sender, ServingEventArgs e)
        if (!ExtensionManager.ExtensionEnabled("PostPaging"))

        if (!e.Body.Contains(_separator))

        _post = (Post)sender;

        if(e.Location == ServingLocation.SinglePost || e.Location == ServingLocation.PostList)
            e.Body = e.Body.Replace(_separator, "");

    private static void BreakToPages(ServingEventArgs e)
        string[] separator = new string[] { _separator };
        _pages = e.Body.Split(separator, StringSplitOptions.RemoveEmptyEntries);

        int iPage = 0;
        var currentPage = HttpContext.Current.Request.QueryString["page"];

        if (!string.IsNullOrEmpty(currentPage))
            int.TryParse(currentPage, out iPage);
            if (iPage > 0)

        if (iPage >= _pages.Count())

        e.Body = _pages[iPage] + Pager(iPage);

    private static string Pager(int current)
        var links = "<div class=\"pagelinks\">Pages: ";
        for (int i = 0; i < _pages.Count(); i++)
            if (i == current)
                links += string.Format("<span> {0} </span>", i + 1);
                links += string.Format("<span> <a href=\"{0}?page={1}\">{1}</a> </span>", _post.RelativeLink, i + 1);
        return links + "</div>";


Comments (3) -

  • Andy McKay

    12/12/2015 10:38:48 AM |

    Nice, see great potential for this, especially when combined with a contents list that heads each  page section with a "Go to page" link. Example http://www.techradar.com/reviews/pc-mac/pc-components/storage/disk-drives-hdd-ssd/crucial-mx100-512gb-1269467/review/1

  • Andrew Kim

    1/10/2016 10:15:27 PM |

    Hi Rtur,

    Your extension is exactly what my website is looking for.. however, upon trying to install it, the error message "fail" comes up and I am unable to install it. Do you have any idea why?

    • rtur.net

      1/13/2016 10:09:42 PM |

      Are you able to install other plugins?

Comments are closed