Using BlogEngine.net as a General Purpose Content Management System – Part I

So I keep running into the same problem – I am building a small website for somebody (in this case, my Mom) and I need to provide them with a way to update the content of their site so I don’t have to. Basically, I need a lightweight and flexible content management system that is easy to use.

In this series of posts, I will show how I converted a small website from just standard .aspx pages into a site where all pages are editable by Windows Live Writer and via an online interface. In Part I of this series I will just set some background on how I am approaching the creation of this lightweight CMS.

If The Shoe Fits…

cmsWhen I first thought of a lightweight CMS, I thought of graffiti. It sounds like exactly what I need. So I downloaded the express edition and started evaluating it. It seemed like a nice product and all is not free for commercial use ($399 is the cheapest commercial licence) and I can’t afford that price tag when building small websites.

Enter BlogEngine.net. My favorite blogging platform. There, I said it. I host my blog on wordpress but I like BlogEngine.net better. In fact, I will probably be migrating to BlogEngine.net in the near future. How do I know I like it so much? Well, I use it to run my wife’s blog and I am constantly tinkering around with her site all of the time because I enjoy using BlogEngine.net so much.

I thought that BlogEngine.net has all of the key pieces I needed for my lightweight CMS:

  1. A WYSIWYG Editor
  2. A Metaweblog interface
  3. Tons of extensibility

Basic Idea

I decided to base my CMS implementation on the concept of pages. Most blog engines have two distinct types of content: pages and posts. Posts are the typical type of content that becomes part of your blogs feed whereas pages are usually static content which can be anything outside of a blog post (for example an ‘About Me’ page). BlogEngine.net already has everything I need to get the content of page created and persisted in a data store (it supports xml and sql server out of the box). I decided to write a web control which I can place on any webpage and include the contents of a given page from the data store.

I made a control called PageViewer which you can place on the page like this:

<blog:PageViewer ID="view" runat="server" DisplayTitle="false"
    PageId="167eb7f3-135b-4f90-9756-be25ec10f14c" />

This control basically just looks up the page using the given id (this functionality is all provided by the existing BlogEngine.Core library) and displays its content. Here is the rendering logic

BlogEngine.Core.Page page = null;
if (PageId != Guid.Empty)
    page = BlogEngine.Core.Page.GetPage(PageId);

if (page != null)
{
    ServingEventArgs arg = new ServingEventArgs(page.Content, ServingLocation.SinglePage);
    BlogEngine.Core.Page.OnServing(page, arg);

    if (arg.Cancel)
        Page.Response.Redirect("error404.aspx", true);

    if (DisplayTitle)
    {
        writer.Write("<h1>");
        writer.Write(page.Title);
        writer.Write("</h1>");
    }

    writer.Write("<div>");
    writer.Write(arg.Body);
    writer.Write("</div>");
}

This code is pretty straight forward – all it does is get an instance of the page and then display its title in <h1> a tag and its body in <div> tag. This logic is actually straight from the existing page retrieval code that already exists in BlogEngine.net. This web control is pretty much the only new code I had to write. The rest of the project mostly involves moving files around and removing parts of the BlogEngine.net framework that I don’t need.

Armed with this control, we are ready to start converting the static pages from the old version of the website to be BlogEngine.net pages which can be stored and retrieved using the BlogEngine.Core classes.

In part II of this series, I will cover what changes I made to the website project used for BlogEngine.net blogs to make it function like a straight up website, not a blog. Any feedback is welcome.

kick it on DotNetKicks.com

About these ads

15 Responses to Using BlogEngine.net as a General Purpose Content Management System – Part I

  1. capgpilk says:

    Nice intro, I have used BlogEngine.net to create departmental pages on our company Intranet. I especially like the way you can use Live Writer to create posts. Like yourself, I have removed quite a lot of the functionality of BlogEngine.net with plans to slowly introduce them over time as the users get more acustomed to it. looking forward to part 2.

  2. Great start. I’m looking forward to seeing what comes next in your series. I would really like to see page management improved a bit in BlogEngine.NET. Two points that come to mind are…

    1. Slugs – the title of my page should not have to be my URL
    2. Delete – the administration area should allow you to delete a page without visiting the front-end view

    Keep up the good work! And I completely agree, BlogEngine.NET is AWESOME!

  3. y0mbo says:

    I recently started building my business’s website using BlogEngine. I gave up on a strategy for doing so to start with and just implemented the blog. I would like to have it be more content (page) focused, so I thought of creating a user control similar to the one you have created. Glad others think like I do! I like how it gives you total control over the page so you can eliminate the sidebar from pages outside of the blog.

  4. Al Nyveldt says:

    Cool idea. I look forward to seeing more of what you are doing.

    We are improving page support in BlogEngine.NET and I hope to see a big improvement in 1.4 this spring.

  5. Jason Kealey says:

    Cool, a more advanced solution that our dirt simple CMS using the ScrewTurn Wiki :)

  6. greg1 says:

    cool idea, sounds interesting!!

  7. Scott says:

    I was wondering why you were using wordpress until I read further into your blog. Haha. This is definitely a great idea. I just had one of those moments of why didn’t I think of this.

  8. A Capital idea. Looks like from some comments that it will be even better from a support standpoint in a couple months. Keep it up and bring out the rest of your series.

  9. BlogeEngine.NET is excellent tool for small and big time bloggers. The XML capability will allow you to easily move from one server to another. My blog is in BlogEngine.NET. and I just love this stuff!!

  10. Blogengine is really a great idea to start our own blogs..I have also created my own blog on it

  11. perdonar says:

    perdonar…

    […]Using BlogEngine.net as a General Purpose Content Management System – Part I « Spontaneous Publicity[…]…

  12. The more traffic a website has the more bandwidth necessary.

    A coupon code might be just what you need to make it affordable – but it does you no good if it only makes it affordable for the first year of your hosting.
    Most web hosts provide a file manager that allows you
    to upload, download and alter the files required for your website from an online control panel.

  13. Wow, that’s what I was seeking for, what a data! existing here at this web site, thanks admin of this web site.

  14. shock rock says:

    I have read so many articles or reviews about the blogger
    lovers but this article is in fact a good post, keep it up.

  15. Hey there just wanted to give you a quick heads up.

    The words in your post seem to be running off the screen in Firefox.
    I’m not sure if this is a format issue or something to do with browser compatibility but I figured I’d post to let you know.
    The layout look great though! Hope you get the issue fixed soon. Many thanks

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: