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...
When 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:
- A WYSIWYG Editor
- A Metaweblog interface
- Tons of extensibility
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"
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:
if (page != null)
ServingEventArgs arg = new ServingEventArgs(page.Content, ServingLocation.SinglePage);
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.