Spontaneous Publicity
blogs are the new phone book

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

February 29, 2008 16:32 by Luke

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: [code=ASPX] [/code] 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 [code=csharp] 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("

"); writer.Write(page.Title); writer.Write("

"); } writer.Write("
"); writer.Write(arg.Body); writer.Write("
"); } [/code] 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
Tags:
Categories:
Actions: E-mail | del.icio.us | Permalink | Comments (17) | Comment RSSRSS comment feed

Comments

March 2. 2008 00:00

capgpilk

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.

capgpilk

March 2. 2008 02:27

Danny Douglass


          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!
        

Danny Douglass

March 2. 2008 03:30

y0mbo

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.

y0mbo

March 2. 2008 03:43

Al Nyveldt


          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.
        

Al Nyveldt

March 2. 2008 05:20

Jason Kealey

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

Jason Kealey

March 4. 2008 23:32

greg1

cool idea, sounds interesting!!

greg1

March 5. 2008 02:18

Scott

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.

Scott

March 7. 2008 21:52

Peter Bromberg

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.

Peter Bromberg

March 28. 2008 09:37

Alejandro

Keep up the good work.

Alejandro

March 28. 2008 09:49

Test de autoescuela


  This post is very good. But i think that Blogengine isn'tthe best way for a general purpose CMS. What do you think?

    Best regards

Test de autoescuela

April 6. 2008 21:02

Ervin Ter

I have never see such a wonderful blogging platform written in C# where it is so extensible. Looking forward to see your part II. Keep the good work up.

Ervin Ter

April 25. 2008 06:03

Codes Web

thanks you

Codes Web

May 10. 2008 00:21

Tagesgeld

BlogEngine.NET is an awesome project, that implemented lots of great ideas. It´s theming, the extensions, everything is almost perfect.

Tagesgeld

August 12. 2008 06:25

Digvijay

Hi,

Very nice post.

Can you put the code for your contro las a zip here?

Thanks in advance.

Digvijay

August 31. 2008 00:36

rich


Very nice post.

Can you put the code for your contro las a zip here?

rich

September 14. 2008 13:54

Lee

Yep if you could add it as a zip that would be awesome - Thanks

Lee

October 29. 2008 10:38

Kunal Mehta

Hi Luke,

You are really doing great job. The pager control will be really increase the power of  blogEngine.Net that becomes CMS.

But I think need more this kind of extension to blogEngine.NET use as Complete CMS Solutions.

I also love BlogEngine.NET in compare to wordpress. I also use BlogEngine.NET on my website: http://elevatesoftsolutions.in/default.aspx - been using it for a few months now.

Kunal Mehta
---
SplendidCRM - First open source CRM application in .NET
www.elevatesoftsolutions.in/.../...ion-in-NET.aspx

Kunal Mehta